我已经下载并安装了 Apache 2.4.4(现在带有 mod_lua 模块)。像这样启用它:
--httpd.conf--
LoadModule lua_module modules/mod_lua.so
AddHandler lua-script .lua
并运行了一个简单的脚本,它就可以工作了。
--htdocs/hello.lua--
function handle(r)
r.content_type = "text/html"
r:puts("Hello Lua World!\n")
end
我现在想连接到本地 pg 数据库,但无法正常工作。
function handle(r)
r.content_type = "text/html"
r:puts("Hello Lua World!\n")
local db, err = r:dbacquire("postgres", "postgres://user:secret@localhost/db0")
if not err then
r:puts("connected!")
else
r:puts("couldn't connect!")
end
end
没有任何错误信息。我是否缺少进一步的配置?
感谢任何输入!
最佳答案
Apache httpd 基于APR提供数据库连接; 因此请确保您的 APR 安装支持您要使用的数据库层。
关于apache - 无法从 mod_lua 连接到 postgresql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15207968/