openresty开发环境搭建

时间:2019-05-25作者:klpeng分类:IT综合浏览:2062评论:0

前言

下载openresty

下载地址:http://openresty.org/cn/download.html
openresty开发环境搭建
下载64位的
下载后解压到:D:\publictools\openresty-1.15.8.1-win64
openresty开发环境搭建

插件安装

打开IDEA找到插件安装

  • lua
  • nginx_supports
  • openresty_lua_supports

HelloWorld

新建一个Lua项目

openresty开发环境搭建

  • 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 'demo01/?.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 demo01/test.lua;
        }
    }
}
  • test.lua
local function main()
    ngx.say("welcome to openresty world!")
end
main()
  • build.xml
<?xml version="1.0" encoding="UTF-8"?>

<project name="demo01" default="dist" basedir=".">
    <description>
        run pic-server
    </description>
    <!-- set global properties for this build -->
    <property name="openresty-home" location="D:\publictools\openresty-1.15.8.1-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}/${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>

配置Nginx服务

  • Edit Configurations
    openresty开发环境搭建
  • 添加nginx server
    openresty开发环境搭建
    -配置Nginx
    openresty开发环境搭建
    openresty开发环境搭建
    openresty开发环境搭建

启动服务

构建

点击dist即可构建
openresty开发环境搭建

启动nginx

选择配置的nginx服务并启动
openresty开发环境搭建

访问页面

访问127.0.0.1:10000/test
openresty开发环境搭建

打赏
文章版权声明:除非注明,否则均为彭超的博客原创文章,转载或复制请以超链接形式并注明出处。
相关推荐

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

猜你喜欢