您的位置:首页 > 运维架构 > Linux

搭建lua开发环境(mac&&linux)

2017-11-22 23:04 531 查看
linux

mkdir lua
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz tar zxvf lua-5.1.4.tar.gz
cd lua-5.1.4
make linux test
make install
yum install readline-devel
cd ..
wget http://luarocks.org/releases/luarocks-2.1.0.tar.gz tar zxvf luarocks-2.1.0.tar.gz
cd luarocks-2.1.0
./configure --with-lua=/usr/local --with-lua-include=../lua-5.1.4/src
make
make install
luarocks install redis-lua


mac

mkdir lua
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz tar zxvf lua-5.1.4.tar.gz
cd lua-5.1.4
make macosx test
make install
cd ..
wget http://luarocks.org/releases/luarocks-2.1.0.tar.gz tar zxvf luarocks-2.1.0.tar.gz
cd luarocks-2.1.0
./configure --with-lua=/usr/local --with-lua-include=../lua-5.1.4/src
make
make install
luarocks install redis-lua


测试 helloworld.lua

function test()
local redis = require "redis"
local client = redis.connect('127.0.0.1',6379)
-- client:auth("123456")
local response = client:ping()
return response
end
print(test())


输出

$ lua helloworld.lua
true
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: