安装方式:
wget http://luarocks.org/releases/luarocks-2.2.2.tar.gz tar zxvf luarocks-2.2.2.tar.gz cd luarocks-2.2.2 ./configure --help
configure help
查看所支持的安装配置,这里咱们主要关注如下两个bash
--prefix=DIR Prefix where LuaRocks should be installed. Default is /usr/local --with-lua=PREFIX Use Lua from given prefix. Default is auto-detected (the parent directory of $LUA_BINDIR).
--prefix
设置 Luarocks 安装路径,--with-lua
指定 Luarocks 依赖的 Lua 安装路径。socket
--prefix
设置 prefix 会自动将 Luarocks 以及日后使用 Luarocks 安装的 Lua 包,LuaC 包都安装到 Luarocks 安装路径下的相应位置,不然相关的包文件散落在文件系统中,显得杂乱不便于管理,若是所安装的 Lua 模板包含 bin 文件,则会自动安装到此目录下的 bin 路径,与 Luarocks 可执行文件同一路径,更便于管理、使用。ui
./configure --prefix=/usr/local/luarocks --with-lua=/usr/local/lua make build make instal
安装以后将
/usr/local/luarocks/bin 添加环境变量可直接运行 luarocks install luasocket //安装socket 模块安转模块完成后 在lua脚本中调用 require("socket") 报错模块找不到 须要将 luarocks 目录中的 /usr/local/luarocks/share/lua/5.3/ 链接到 /usr/local/share/lua下 /usr/local/luarocks/lib/lua/5.3 链接到 /usr/local/lib/lua