Dict.CN 在线词典, 英语学习, 在线翻译 ------------- MyGitee 朱秋贵内科诊所 My腾云code

idea+OpenResty

1、安装OpenResty

 

 

 

2、IDEA插件

   Lua,nginx Support,OpenResty Lua Support

  ant 发布运行

  

 

 

 

 

 

3、创建lua项目

 

 

 

  3.1)

 

创建conf\nginx.conf 内容如下:

   worker_processes 1;
error_log logs/error.log info;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
access_log logs/access.log;
lua_package_path 'luademo1/?.lua;;';
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 luademo1/helloworld.lua;
}
}
}

 

 


     src\helloworld.lua文件

---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by admin.
--- DateTime: 2024/1/8 14:22
---

local hello = function ()
ngx.say("Hello world,Lua!")
end

hello()

 

 


     build.xml

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

<project name="luademo1" default="dist" basedir=".">
<description>
run pic-server
</description>
<!-- set global properties for D:\tools\openresty-1.19.3.1-win64 this build -->
<property name="openresty-home" location="D:\tools\openresty-1.19.3.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>

 3.2) nginx.conf编辑类型

 

 

 

4、IDEA中配置openresty及ant


 

 

 

 

配置Ant Build,用于将confsrc中的文件拷贝到OpenResty安装目录下的指定路径D:\tools\openresty-1.19.3.1-win64

右键build.xml文件,选中Add as Ant Build File

    • 点击Ant中的Run执行一下

 

 

 

 

 

 

 

 

 

 

 

运行Ant,在OpenResty安装目录下看到文件已经拷贝

 

 

5、IDEA中启动openresty

   先启动ant

 

 

 

 

启动openresty

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2024-01-08 15:15  cn2024  阅读(94)  评论(0编辑  收藏  举报