6

我对 nginx 和 lua 非常陌生。我已经安装了 Openresty。下面是我在 nginx.conf 文件中的代码。

服务器{
      位置 /hellolua {
      default_type '文本/纯文本';
        content_by_lua ' 本地名称 = ngx.var.arg_name 或“匿名”
        ngx.say("你好, ", 名字, "!") ';
        }
       }

当我跑步时

sudo 服务 nginx 启动
我收到错误
启动 nginx: nginx: [emerg] 未知指令 "content_by_lua" 在 /etc/nginx/nginx.conf:24
nginx:配置文件 /etc/nginx/nginx.conf 测试失败
请让我知道我缺少什么。

4

2 回答 2

6

在我看来,好像您没有安装正确的模块?ngx_lua ( http://wiki.nginx.org/HttpLuaModule )

你提到了 OpenResty。你是用lua配置的吗?如果没有,指南在这里(http://wiki.nginx.org/HttpLuaModule#Installation)。
快速简历:

ngx_openresty 包可用于安装 Nginx、ngx_lua、标准 Lua 5.1 解释器或 LuaJIT 2.0 之一,以及强大的 Nginx 配套模块包。基本安装步骤很简单./configure --with-luajit && make && make install.

您也可以手动将 ngx_lua 编译到 nginx 中,完整指南也在链接中。

在评论讨论之后 - 我删除了答案中不相关的部分。

于 2013-11-08T08:29:40.463 回答
4

默认情况下,OpenResty 的 nginx 安装在路径/usr/local/openresty/nginx/sbin/nginx中。您系统的默认 nginx 初始化配置需要更新以指向正确的位置。

于 2013-11-19T19:43:07.917 回答