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