luarocks 包管理工具

安装方式:
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 查看所支持的安装配置,这里我们主要关注以下两个

--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 安装路径。

为何强调设置 --prefix

设置 prefix 会自动将 Luarocks 以及往后使用 Luarocks 安装的 Lua 包,LuaC 包都安装到 Luarocks 安装路径下的相应位置,否则相关的包文件散落在文件系统中,显得杂乱不便于管理,如果所安装的 Lua 模板包含 bin 文件,则会自动安装到此目录下的 bin 路径,与 Luarocks 可执行文件同一路径,更便于管理、使用。

 
./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









posted @ 2016-12-13 12:47  塔塔尔兀格  阅读(856)  评论(0)    收藏  举报