apache - 无法从 mod_lua 连接到 postgresql

标签 apache postgresql lua mod-lua

我已经下载并安装了 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/

相关文章:

apache - 本地主机上的 WordPress 永久链接帖子名称 404

apache - 在端口 80 上运行 Opa 服务器

json - jsonb 字段中的 PostgreSQL 重命名属性

postgresql - 在 Postgres 中分组事件

postgresql - 应该使用哪种数据类型来存储 GeoJSON 对 Postgres 的响应

lua - 确定 Lua 编译器是运行 32 位还是 64 位

wordpress - 如何在 bitnami wordpress ubuntu 实例上升级 apache

php - htaccess 将带有查询字符串的域重定向到带有排除的子域

c++ - 重构 C++ 代码以使用脚本语言?

file-io - 使用 Lua io.read ('*a' 从图像文件获取所有数据的问题)