标签搜索

目 录CONTENT

文章目录
Lua

linux安装lua、lua包管理工具luarocks和postgresql依赖

陈铭
2021-06-22 / 0 评论 / 0 点赞 / 144 阅读 / 269 字 / 正在检测是否收录...

安装lua和luarocks

添加环境变量

vi /etc/profile
# 结尾追加
LUA_MAJOR_VERSION=5.3
export LUA_MAJOR_VERSION
LUA_MINOR_VERSION=4
export LUA_MINOR_VERSION
LUA_VERSION=5.3.4
export LUA_VERSION
WITH_LUA=/usr/local/
export WITH_LUA
LUA_LIB=/usr/local/lib/lua
export LUA_LIB
LUA_INCLUDE=/usr/local/include
export LUA_INCLUDE
LUAROCKS_VERSION=2.4.2
export LUAROCKS_VERSION
LUAROCKS_INSTALL=luarocks-2.4.2
export LUAROCKS_INSTALL
TMP_LOC=/tmp/luarocks
export TMP_LOC

安装

yum install -y wget make gcc readline-devel unzip zip git
wget http://www.lua.org/ftp/lua-5.3.4.tar.gz
tar -zxvf lua-5.3.4.tar.gz && cd lua-5.3.4
make linux test && make install
rm -rf /lua-5.3.4*

cd / && wget https://luarocks.org/releases/luarocks-2.4.2.tar.gz
tar -zxvf luarocks-2.4.2.tar.gz && cd luarocks-2.4.2
./configure && make build && make install
rm -rf /luarocks-2.4.2*

postgresql依赖

安装postgresql依赖

yum install postgresql-devel -y
luarocks install luasql-postgres PPGSQL_LIBDIR=/usr/lib PGSQL_INCDIR=/usr/include

测试

lua
luasql = require "luasql.postgres"
env = luasql.postgres()
conn = env:connect("dbname", "username", "password", "159.75.26.246", 5432)
conn:execute("INSERT INTO LOG (log) VALUES ('GGGGG');")

返回1.0,说明成功插入数据一行

0

评论区