windows10下OpenResty环境配置,


1、idea安装

2、配置idea插件,需要安装两个插件,lua(或者EmmyLua)和nginx Support

3、openresty

http://openresty.org/cn/download.html

4、解压openresty-1.13.6.2-win64.zip,双击nginx.exe,访问localhost如果看到hello openresty,则以安装完成

5、idea配置nginx server

nginx Executable : 选择安装openresty后nginx.exe

configuration File : nginx配置文件,可选择自己项目路径中的nginx.conf文件

Pid file :nginx 进程文件,可在自己项目路径中指定

安装之后运行,就可以通过idea启动nginx了,但是我们项目路径一般不再openresty下,所以需要把两个文件路径做个映射

6、文件路径映射

项目路径下创建ant需要的build.xml文件

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

<project name="OpenResty" default="dist" basedir="D:/workspace/OpenResty">
    <description>
        run pic-server
    </description>
    <!-- set global properties for this build -->
    <property name="openresty-home" location="D:\openresty\openresty-1.13.6.2-win64"/>
    <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}/src"/>

    <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>

修改basedir:项目跟路径

openresty-hemo:安装openresty的路径

7、添加ant

8、在nginx server配置中增加,使每次运行之前先执行ant,完成文件copy

需要注意区分两个路径,一个是自己项目的路径,另外一个是openresty的安装路径,我们喜欢将他们去跟开来,这样就需要每次执行前将自己项目路径中的src文件和nginx.conf文件copy到openresty的安装路径,上面ant配置就是为了完成这个。

相关内容

    暂无相关文章