如何在 Linux CentOS 7 上安装 luasql?

How to install luasql on Linux CentOS 7?

我尝试使用以下命令在我的 Linux CentOS 7 计算机上安装 luasql

luarocks install luasql-postgres

但不幸的是我收到以下错误:

Installing https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/luasql-postgres-2.3.5-2.rockspec...
Using https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/luasql-postgres-2.3.5-2.rockspec... switching to 'build' mode

Error: Could not find header file for PGSQL
  No file libpq-fe.h in /usr/local/include
  No file libpq-fe.h in /usr/include
You may have to install PGSQL in your system and/or pass PGSQL_DIR or PGSQL_INCDIR to the luarocks command.
Example: luarocks install luasql-postgres PGSQL_DIR=/usr/local

然后我尝试 运行 最后一行 luarocks install luasql-postgres PGSQL_DIR=/usr/local 但我没有任何改进...

我该怎么办?

这Lua位没问题;你得到的错误是 C 位不存在。

一般来说,当您与 C 库交互时,您需要确保安装了 C 库的 -dev(对于 Debianish)或 -devel(对于 Redhatish)包。

在你的情况下,你可以在你的盒子上以 root 身份执行以下操作:

yum install postgresql-devel

...然后再次尝试安装 luarocks。

或者,您可以尝试使用 OS 本机包:

yum install lua-sql-postgresql

我个人更喜欢将 OS 软件包用于稳定的 Lua 库,这些库不会有太大变化,但这是您的决定...