在 cgilua.lua 的第 93 行 SAPI 是空值

我正在尝试在我的服务器上安装和配置 cgilua。我已经通过 apt-get 安装了 Apache 和 lua(5.2.1.4),并通过 luarocks 安装了 cgilua(5.2.1-1)。在 Apache 上,我使用 a2enmod 命令添加了 lua_mod。我创建了一个 lua.conf 文件来将 lua-脚本与 lua 和 lp 文件关联起来。

为了测试一切是否顺利,我使用了这段代码:

#!/usr/bin/env lua

cgilua = require "cgilua"

cgilua.htmlheader()

if cgilua.QUERY.language == 'english' then
   greeting = 'Hello World!'
elseif cgilua.QUERY.language == 'portuguese' then
   greeting = 'Olá Mundo!'
else
   greeting = '[unknown language]'
end

cgilua.put('<html>')
cgilua.put('<head>')
cgilua.put('  <title>'..greeting..'</title>')
cgilua.put('</head>')
cgilua.put('<body>')
cgilua.put('  <strong>'..greeting..'</strong>')
cgilua.put('</body>')
cgilua.put('</html>')

我一直得到这个错误:

[lua:error] [pid 14909] AH02613: Error loading /var/www/html/lua/index.lua: /usr/local/share/lua/5.2/cgilua.lua:93: attempt to index upvalue 'SAPI' (a nil value)

谁能解释一下这个问题呢?

点赞