idea搭建lua开发openresty程序的环境

下载openresty

下载地址:http://openresty.org/cn/download.html

解压后如下图所示:

安装idea插件

安装Emmylua

安装nginx Support

创建lua项目

创建项目如下(注:该项目为java项目):

创建好项目后,在根目录下创建conf文件夹,在conf文件夹下创建nginx.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;
    server {
        listen       8080;
        server_name  localhost;
        default_type text/html;
        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }
 
        location /test {
            content_by_lua_file  openresty_lua/test.lua;
        }
    }
}

 在根目录下创建build.xml文件,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<project name="openresty_lua" default="dist" basedir=".">
    <description>
        run openresty_lua
    </description>
    <!-- set global properties for this build -->
    <property name="openresty-home" location="c:\code\openresty-1.27.1.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>

 idea配置openresty环境

点击如下红框所示一步一步操作:

启动,访问http://localhost:8080如下图所示表示配置成功:

Ant构建

Ant添加build.xml:

自动构建项目

编写lua代码并运行

在src目录下创建test.lua文件,代码如下:

local function main()
    ngx.say("hello")
end
main()

启动服务:

访问http://localhost:8080/test

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值