openresty下安装luarocks

wget https://luarocks.org/releases/luarocks-2.4.1.tar.gz
 
tar -xzvf luarocks-2.4.1.tar.gz
 
cd luarocks-2.4.1/
 
./configure --prefix=/usr/local/openresty/luajit \
    --with-lua=/usr/local/openresty/luajit/ \
    --lua-suffix=jit \
    --with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1
make build
# 安装需要root权限
sudo make install

此处要做说明的是

--prefix 设定 luarocks 的安装目录

--with-lua 则是系统中安装的 lua 的根目录

--lua-suffix 版本后缀,此处因为openresyt的lua解释器使用的是 luajit ,所以此处得写 jit

--with-lua-include 设置 lua 引入一些头文件头文件的目录

之后我们就可以看到 luarocks 命令就被安装在了 /usr/local/openresty/luajit/bin 下面

 

然后我们把它添加到到 PATH 中

vi ~/.bash_profile

export PATH=$PATH:/usr/local/openresty/luajit/bin

执行 luarocks install package 就可以安装lua的包了
luarocks install package --tree=path 还可以指定你安装的包的存放路径

posted @ 2019-08-23 15:55  王东波  阅读(285)  评论(0编辑  收藏  举报