栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

OpenRestry实战二:idea搭建Lua+OpenResty+Nginx开发环境

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

OpenRestry实战二:idea搭建Lua+OpenResty+Nginx开发环境

idea搭建Lua+OpenResty+Nginx开发环境

1.下载openrestry并解压到本地:

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

2.安装插件:Lua,openrestyLuaSupport,idea-nginx-support

参考地址:https://blog.csdn.net/u014079773/article/details/101062867

3.配置nginx服务:

点击"OK",选择已添加的nginx

配置nginx.conf文件打开方式,设置完成之后,我们看到的nginx.conf文件中语法就高亮显示了。

到此环境配置结束,接下来测试案例:

创建一个Lua工程:

创建好后,在根目录下创建conf文件夹,build.xml文件,在conf文件夹下创建nginx.conf文件,在src目录下创建test.lua文件。整个项目结构如下:

配置文件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 'myLua/?.lua;;';
    server {
        listen       80;
        server_name  localhost;
        default_type text/html;
        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

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

文件build.xml:



    
        run myLua
    
    
    
    
    
    
    

    ######开发版本的ant配置#####
    
        清理openresty目录 ${dist}下的conf,logs,janus,januslib
        
        
        
            
        
    

    
        创建安装目录
        
        
    

    
        复制安装文件
        
            
        
        
            
        
    


文件test.lua

local function main()
    ngx.say("Hello World,This is my first lua!");
end;

main()

Ant build添加build.xml构建:

使用idea nginx support插件自动化构建项目,idea启动nginx

到此环境配置完成

idea启动nginx:

本地启动成功,访问test.lua:http://localhost/test

总结:

配置ant主要目的将当前项目复制到myLua路径下

build.xml主要目的配置myLua工作路径及idea工程配置文件路径

错误定位:

通常情况下nginx启动、运行出现的错误都会记录日志,在logs目录下的error.log文件可以看到日志记录,这样有利于我们排查问题。

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/268634.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号