我已经下载并安装了Apache 2.4.4(现在带有mod_lua模块)。像这样启用它:
--httpd.conf--
"并且运行了一个简单的脚本,它可以工作。
--htdocs/hello.lua--"
我现在想连接到一个本地的pg数据库,但是无法使其工作。
没有任何错误消息。我错过了进一步的配置吗?
谢谢任何意见!
--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
没有任何错误消息。我错过了进一步的配置吗?
谢谢任何意见!
puts()
调用之后,还要包括一个db:close()
。 - hjpotter92