1. 程式人生 > >idea配置openresty(windows環境)

idea配置openresty(windows環境)

1. 下載

2. 解壓到D:\develop\openresty

3. idea安裝openresty外掛

配置nginx

1. 安裝nginx support外掛

2. 配置nginx server

配置環境變數OpenResty

path配置D:\develop\openresty

新建lua工程

conf目錄下新建nginx.conf

worker_processes  2;
error_log  logs/error.log  info;
events {
  worker_connections  1024;
}
http {
  default_type  application/octet-stream;
  access_log  logs/access.log;
  lua_package_path 'luademo/?.lua;;';
  server {
    listen       10000;
    server_name  localhost;
    default_type text/html;
    location = /favicon.ico {
      log_not_found off;
      access_log off;
    }

    location /test {
      content_by_lua_file luademo/test.lua;
    }
  }
}

src目錄下新建test.lua

local function main()
    ngx.say("welcome to openresty world!")
end
main()

idea配置ant

<?xml version="1.0" encoding="UTF-8"?>

<project name="luademo" default="dist" basedir=".">
    <description>
        run pic-server
    </description>
    <!-- set global properties for this build -->
    <property name="openresty-home" location="D:\develop\openresty"/>
    <property name="conf" location="${basedir}/conf"/>
    <property name="src" location="${basedir}/src"/>
    <property name="target-conf" location="${openresty-home}/conf"/>
    <property name="target-src" location="${openresty-home}/${ant.project.name}"/>

    <echo>######開發版本的ant配置#####</echo>
    <target name="clean" depends="">
        <echo>清理openresty目錄 ${dist}下的conf,logs,janus,januslib</echo>
        <delete dir="${target-conf}"/>
        <delete dir="${target-src}"/>
        <delete>
            <fileset dir="${openresty-home}/logs" includes="*.log">
            </fileset>
        </delete>
    </target>

    <target name="init" depends="clean">
        <echo>建立安裝目錄</echo>
        <mkdir dir="${target-conf}"/>
        <mkdir dir="${target-src}"/>
    </target>

    <target name="dist" depends="init" description="generate the distribution" >
        <echo>複製安裝檔案</echo>
        <copy todir="${target-conf}">
            <fileset dir="${conf}"></fileset>
        </copy>
        <copy todir="${target-src}">
            <fileset dir="${src}"></fileset>
        </copy>
    </target>

</project>

ant build新增ant target

新增ant target

執行

瀏覽器訪問

test路徑訪問