CentOS 7 下搭建lua+luarocks运行环境

来源:互联网 发布:淘宝商机助理在哪里 编辑:程序博客网 时间:2024/05/21 08:59

step1:安装依赖

yum install gcc gcc-c++ kernel-devel

yum install readline-dev

yum install ncurses-devel.i386


step2:安装lua

wget http://www.lua.org/ftp/lua-5.1.5.tar.gz

tar zxvf lua-5.1.5.tar.gz

cd lua-5.1.5

vi Makefile

INSTALL_TOP= /usr/local/lua-5.1.5

make linux

make install


step3:安装luarocks 

wget http://keplerproject.github.io/luarocks/releases/luarocks-2.2.2.tar.gz

tar -xzvf luarocks-2.2.2.tar.gz

cd luarocks-2.2.2

./configure --prefix=/usr/local/luarocks-2.2.2 --with-lua=/usr/local/lua-5.1.5

make build

make install


step4:配置环境变量 

PATH=$PATH:$HOME/bin:/usr/local/luarocks-2.2.2/bin:/usr/local/lua-5.1.5/bin

export PATH 

export LUA_PATH="/usr/local/luarocks-2.2.2/share/lua/5.1/?.lua;?.lua;;"

export LUA_CPATH="/usr/local/luarocks-2.2.2/lib/lua/5.1/?.so;?.so;;"


step5:安装luasocket 

luarocks install luasocket


step6:测试

lua进入交互命令行

输入require "socket"

回车

不报错说明成功了!