nginx+lua (一)

项目工程结构

hello

    hello.conf     

    lua              

      hello.lua

    lualib            

      *.lua

      *.so

新建hello.conf

server {  

    listen       80;  

    server_name  _;  

    location /lua {  

        default_type 'text/html';  

        lua_code_cache off;  

        content_by_lua_file /usr/example/lua/test.lua;  

    }  

}  

新建 test.lua脚本

ngx.say("hello world"); (测试脚本)

增加配置

/usr/servers/nginx/conf/nginx.conf

在http中 include /usr/hello/hello.conf;  

查看异常日志

tail -f /usr/servers/nginx/logs/error.log

重新nginx加载配置

/usr/servers/nginx/sbin/nginx -s reload  

原文地址:https://www.cnblogs.com/qingducx/p/7629405.html