1.最好新建一个你自己的目录,然后把lua + Luarocks 都安装在这个文件夹下面,方便以后维护
2.安装lua环境
$ wget http://www.lua.org/ftp/lua-5.3.0.tar.gz
$ tar zxvf lua-5.3.0.tar.gz
$ cd lua-5.3.0
$ vi Makefile
INSTALL_TOP= /usr/local/lua-5.3.0 --指定安装的目录
$ make linux
$ make install
3. 安装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.3.0 (luarocks-2.2.2 所在目录,lua-5.3.0配置的安装目录INSTALL_TOP= /usr/local/lua-5.3.0 --指定安装的目录)
$ make build
$ make install
4.重点来了,我执行 ./configure --prefix=/usr/local/luarocks-2.2.2 --with-lua=/usr/local/lua-5.3.0 一直报下面的错误
报错信息:[root@test-l27-15-165 luarocks-2.2.2]# ./configure --prefix=/usr/fxj/luarocks-2.2.2 --with-lua=/usr/local/include/
Checking Lua interpreter... lua not found (looked in /usr/local/include//bin)
You may want to use the flag --with-lua or --with-lua-bin. See --help.
configure failed.
那么这个路径具体该怎么设置呢?
luarocks-2.2.2这会是这个解压包所在的路径,/usr/local/lua-5.3.0这个是INSTALL_TOP= /usr/local/lua-5.3.0
[root@test-l27-15-165 luarocks-2.2.2]# ./configure --prefix=/usr/fxj/luarocks-2.2.2 --with-lua=/usr/local/lua-5.3.0
Lua interpreter found: /usr/local/lua-5.3.0/bin/lua...
Lua version detected: 5.3
Checking Lua includes... lua.h found in /usr/local/lua-5.3.0/include/lua.h
curl found at /usr/bin
md5sum found at /usr/bin
Configuring for system... Linux
Configuring for architecture... x86_64
Using unversioned rocks dir: /usr/fxj/luarocks-2.2.2/lib/luarocks/rocks
Writing configuration...
Installation prefix: /usr/fxj/luarocks-2.2.2
LuaRocks configuration directory: /usr/fxj/luarocks-2.2.2/etc/luarocks
Using Lua from: /usr/local/lua-5.3.0
Done configuring.
- Type 'make build' and 'make install':
to install to /usr/fxj/luarocks-2.2.2 as usual.
- Type 'make bootstrap':
to install LuaRocks in /usr/fxj/luarocks-2.2.2 as a rock.
蓝色为结果
提示找不到lua.h,默认情况下会从/usr下寻找
再次执行:
[root@test-l27-15-165 luarocks-2.2.2]# find / -name = lua.h
find: paths must precede expression: lua.h
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
[root@test-l27-15-165 luarocks-2.2.2]# find / -name lua.h
/usr/fxj/lua-5.3.0/src/lua.h
/usr/local/include/lua.h
/usr/local/lua-5.3.0/include/lua.h
再次执行下面这个命令:
./configure --with-lua=/usr/local --with-lua-include=/usr/local/include
$ make build
$ make install
5.输入下面验证是否安装成功:
[root@test-l27-15-165 luarocks-2.2.2]# luarocks
LuaRocks 2.2.2, a module deployment system for Lua
NAME
/usr/local/bin/luarocks - LuaRocks main command-line interface
SYNOPSIS
/usr/local/bin/luarocks [--from=<server> | --only-from=<server>] [--to=<tree>] [VAR=VALUE]... <command> [<argument>