一、centos安装Lua
3)个人在这里选择使用5.1版本的
*下载
wget http://www.lua.org/ftp/lua-5.1.5.tar.gz
--2013-10-14 16:23:17-- http://www.lua.org/ftp/lua-5.1.5.tar.gz
Resolving www.lua.org... 89.238.129.35, 2a02:40:41::5
Connecting to www.lua.org|89.238.129.35|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 221213 (216K) [application/octet-stream]
Saving to: “lua-5.1.5.tar.gz”
*解压文件
tar -xzvf lua-5.1.5.tar.gz
*安装
[root@xxx lua-5.1.5]# make
Please do
make PLATFORM
where PLATFORM is one of these:
aix ansi bsd freebsd generic linux macosx mingw posix solaris
See INSTALL for complete instructions.
提示输入 参数指定安装的系统平台
[root@xxx lua-5.1.5]# make linux
cd src && make linux
make[1]: Entering directory `/root/down/lua-5.1.5/src'
make all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
make[2]: Entering directory `/root/down/lua-5.1.5/src'
gcc -O2 -Wall -DLUA_USE_LINUX -c -o lua.o lua.c
In file included from lua.h:16,
from lua.c:15:
luaconf.h:275:31: error: readline/readline.h: No such file or directory
luaconf.h:276:30: error: readline/history.h: No such file or directory
lua.c: In function ‘pushline’:
lua.c:182: warning: implicit declaration of function ‘readline’
lua.c:182: warning: assignment makes pointer from integer without a cast
lua.c: In function ‘loadline’:
lua.c:210: warning: implicit declaration of function ‘add_history’
make[2]: *** [lua.o] Error 1
make[2]: Leaving directory `/root/down/lua-5.1.5/src'
make[1]: *** [linux] Error 2
make[1]: Leaving directory `/root/down/lua-5.1.5/src'
make: *** [linux] Error 2
这里又报了个错, 百度了一下,未安装一些必须的开发环境
yum install -y readline-devel ncurses-devel
执行一下上边的安装
然后继续lua的安装
[root@xxx lua-5.1.5]# make linux
cd src && make linux
make[1]: Entering directory `/root/down/lua-5.1.5/src'
make all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
make[2]: Entering directory `/root/down/lua-5.1.5/src'
gcc -O2 -Wall -DLUA_USE_LINUX -c -o lua.o lua.c
gcc -o lua lua.o liblua.a -lm -Wl,-E -ldl -lreadline -lhistory -lncurses
gcc -O2 -Wall -DLUA_USE_LINUX -c -o luac.o luac.c
gcc -O2 -Wall -DLUA_USE_LINUX -c -o print.o print.c
gcc -o luac luac.o print.o liblua.a -lm -Wl,-E -ldl -lreadline -lhistory -lncurses
make[2]: Leaving directory `/root/down/lua-5.1.5/src'
make[1]: Leaving directory `/root/down/lua-5.1.5/src'
下一步:
[root@xxx lua-5.1.5]# make install
cd src && mkdir -p /usr/local/bin /usr/local/include /usr/local/lib /usr/local/man/man1 /usr/local/share/lua/5.1 /usr/local/lib/lua/5.1
cd src && install -p -m 0755 lua luac /usr/local/bin
cd src && install -p -m 0644 lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp /usr/local/include
cd src && install -p -m 0644 liblua.a /usr/local/lib
cd doc && install -p -m 0644 lua.1 luac.1 /usr/local/man/man1
如此安装完成,然后试一下效果:
[root@xxx lua-5.1.5]# lua
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> print("Hello ");
Hello
>
二、centos安装LuaSocket
3)下载并解压
wget http://files.luaforge.net/releases/luasocket/luasocket/luasocket-2.0.2/luasocket-2.0.2.tar.gz
tar -xzvf luasocket-2.0.2.tar.gz
4)安装
[root@xxx luasocket-2.0.2]# make & make install
[1] 2109
cd src; make all
cd src; make all
make[1]: Entering directory `/root/down/luasocket-2.0.2/src'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/root/down/luasocket-2.0.2/src'
make[1]: Entering directory `/root/down/luasocket-2.0.2/src'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/root/down/luasocket-2.0.2/src'
cd src; mkdir -p /usr/local/share/lua/5.1
cd src; cp ltn12.lua socket.lua mime.lua /usr/local/share/lua/5.1
cd src; mkdir -p /usr/local/share/lua/5.1/socket
cd src; cp http.lua url.lua tp.lua ftp.lua smtp.lua /usr/local/share/lua/5.1/socket
cd src; mkdir -p /usr/local/lib/lua/5.1/socket
cd src; cp socket.so.2.0.2 /usr/local/lib/lua/5.1/socket/core.so
#cd src; mkdir -p /usr/local/share/lua/5.1/mime
#cd src; cp /usr/local/share/lua/5.1/mime
cd src; mkdir -p /usr/local/lib/lua/5.1/mime
cd src; cp mime.so.1.0.2 /usr/local/lib/lua/5.1/mime/core.so
[1]+ Done make
5)个人在这里顺利安装成功,哈哈