CentOs 安装lua,luasocket

来源:互联网 发布:手机淘宝4.9.3版本安卓 编辑:程序博客网 时间:2024/04/29 06:43

一、centos安装Lua

1)lua的官网:http://www.lua.org

2)lua的所有版本: http://www.lua.org/versions.html

3)个人在这里选择使用5.1版本的

 *下载 

[plain] view plain copy
  1.  wget http://www.lua.org/ftp/lua-5.1.5.tar.gz  
  2. --2013-10-14 16:23:17--  http://www.lua.org/ftp/lua-5.1.5.tar.gz  
  3. Resolving www.lua.org... 89.238.129.35, 2a02:40:41::5  
  4. Connecting to www.lua.org|89.238.129.35|:80... connected.  
  5. HTTP request sent, awaiting response... 200 OK  
  6. Length: 221213 (216K) [application/octet-stream]  
  7. Saving to: “lua-5.1.5.tar.gz”  
*解压文件

[plain] view plain copy
  1. tar -xzvf lua-5.1.5.tar.gz  

*安装

[plain] view plain copy
  1. [root@xxx lua-5.1.5]# make   
  2. Please do  
  3.    make PLATFORM  
  4. where PLATFORM is one of these:  
  5.    aix ansi bsd freebsd generic linux macosx mingw posix solaris  
  6. See INSTALL for complete instructions.  
提示输入 参数指定安装的系统平台

[plain] view plain copy
  1. [root@xxx lua-5.1.5]# make linux  
  2. cd src && make linux  
  3. make[1]: Entering directory `/root/down/lua-5.1.5/src'  
  4. make all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"  
  5. make[2]: Entering directory `/root/down/lua-5.1.5/src'  
  6. gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lua.o lua.c  
  7. In file included from lua.h:16,  
  8.                  from lua.c:15:  
  9. luaconf.h:275:31: error: readline/readline.h: No such file or directory  
  10. luaconf.h:276:30: error: readline/history.h: No such file or directory  
  11. lua.c: In function ‘pushline’:  
  12. lua.c:182: warning: implicit declaration of function ‘readline’  
  13. lua.c:182: warning: assignment makes pointer from integer without a cast  
  14. lua.c: In function ‘loadline’:  
  15. lua.c:210: warning: implicit declaration of function ‘add_history’  
  16. make[2]: *** [lua.o] Error 1  
  17. make[2]: Leaving directory `/root/down/lua-5.1.5/src'  
  18. make[1]: *** [linux] Error 2  
  19. make[1]: Leaving directory `/root/down/lua-5.1.5/src'  
  20. make: *** [linux] Error 2  

这里又报了个错, 百度了一下,未安装一些必须的开发环境 

[plain] view plain copy
  1. yum install -y readline-devel ncurses-devel  

执行一下上边的安装

然后继续lua的安装

[plain] view plain copy
  1. [root@xxx lua-5.1.5]# make linux  
  2. cd src && make linux  
  3. make[1]: Entering directory `/root/down/lua-5.1.5/src'  
  4. make all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"  
  5. make[2]: Entering directory `/root/down/lua-5.1.5/src'  
  6. gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lua.o lua.c  
  7. gcc -o lua  lua.o liblua.a -lm -Wl,-E -ldl -lreadline -lhistory -lncurses  
  8. gcc -O2 -Wall -DLUA_USE_LINUX   -c -o luac.o luac.c  
  9. gcc -O2 -Wall -DLUA_USE_LINUX   -c -o print.o print.c  
  10. gcc -o luac  luac.o print.o liblua.a -lm -Wl,-E -ldl -lreadline -lhistory -lncurses  
  11. make[2]: Leaving directory `/root/down/lua-5.1.5/src'  
  12. make[1]: Leaving directory `/root/down/lua-5.1.5/src'  
下一步:

[plain] view plain copy
  1. [root@xxx lua-5.1.5]# make install  
  2. 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  
  3. cd src && install -p -m 0755 lua luac /usr/local/bin  
  4. cd src && install -p -m 0644 lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp /usr/local/include  
  5. cd src && install -p -m 0644 liblua.a /usr/local/lib  
  6. cd doc && install -p -m 0644 lua.1 luac.1 /usr/local/man/man1  

如此安装完成,然后试一下效果:

[plain] view plain copy
  1. [root@xxx lua-5.1.5]# lua  
  2. Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio  
  3. > print("Hello ");  
  4. Hello   
  5. >   

二、centos安装LuaSocket

1) LuaSocket源码地址:http://files.luaforge.net/releases/luasocket/luasocket

2)个人选择:http://files.luaforge.net/releases/luasocket/luasocket/luasocket-2.0.2

3)下载并解压

[plain] view plain copy
  1. wget http://files.luaforge.net/releases/luasocket/luasocket/luasocket-2.0.2/luasocket-2.0.2.tar.gz  
  2.   
  3. tar -xzvf luasocket-2.0.2.tar.gz  

4)安装

[plain] view plain copy
  1. [root@xxx luasocket-2.0.2]# make & make install  
  2. [1] 2109  
  3. cd src; make all  
  4. cd src; make all  
  5. make[1]: Entering directory `/root/down/luasocket-2.0.2/src'  
  6. make[1]: Nothing to be done for `all'.  
  7. make[1]: Leaving directory `/root/down/luasocket-2.0.2/src'  
  8. make[1]: Entering directory `/root/down/luasocket-2.0.2/src'  
  9. make[1]: Nothing to be done for `all'.  
  10. make[1]: Leaving directory `/root/down/luasocket-2.0.2/src'  
  11. cd src; mkdir -p /usr/local/share/lua/5.1  
  12. cd src; cp ltn12.lua socket.lua mime.lua /usr/local/share/lua/5.1  
  13. cd src; mkdir -p /usr/local/share/lua/5.1/socket  
  14. cd src; cp http.lua url.lua tp.lua ftp.lua smtp.lua /usr/local/share/lua/5.1/socket  
  15. cd src; mkdir -p /usr/local/lib/lua/5.1/socket  
  16. cd src; cp socket.so.2.0.2  /usr/local/lib/lua/5.1/socket/core.so  
  17. #cd src; mkdir -p /usr/local/share/lua/5.1/mime  
  18. #cd src; cp  /usr/local/share/lua/5.1/mime  
  19. cd src; mkdir -p /usr/local/lib/lua/5.1/mime  
  20. cd src; cp mime.so.1.0.2 /usr/local/lib/lua/5.1/mime/core.so  
  21. [1]+  Done                    make  
5)个人在这里顺利安装成功,哈哈

0 0
原创粉丝点击