Linux系统下如何搭建luarocks环境

 更新时间:2024年06月19日 11:25:06   作者:longxiaobai_WJ  
这篇文章主要介绍了Linux系统下如何搭建luarocks环境问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教

1. notes

  • 本文中 openrestygitnode 为随手记录;
  • 主要搭建 luarocks 环境,测试实现openresty部分功能;

2. luarocks

  • lua或luajit安装一个即可
wget https://luarocks.org/releases/luarocks-3.3.1.tar.gz

tar -zxpf luarocks-3.3.1.tar.gz

luarocks -h

luarocks list

luarocks install luafilesystem
# 还可以指定你安装的包的存放路径
luarocks install package --tree=path 

3. lua - luarocks

yum install -y readline-devel

# 系统原有lua,通过以下命令查看版本
lua -v

# 安装同版本或稳定版本
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz
tar -zxvf lua-5.1.4.tar.gz

# make linux test
cd lua-5.1.4
echo "INSTALL_TOP= /usr/local/lua_5.1.4" >> Makefile
make linux && make install

cd luarocks-3.3.1
# lua - configure
./configure --prefix=/usr/local/luarocks_3.3.1 --with-lua=/usr/local/lua_5.1.4 --with-lua-include=/usr/local/lua_5.1.4/include/

make && make install

# lua require('cjson')
luarocks install lua-cjson

# Maybe Globals Env Note Settings
export LUALOCKS_HOME=/usr/local/luarocks_3.3.1
export LUA_HOME=/usr/local/lua_5.1.4
export LUA_PATH="$LUALOCKS_HOME/share/lua/5.1/?.lua;?.lua;;"
export LUA_CPATH="$LUALOCKS_HOME/lib/lua/5.1/?.so;?.so;;"

export PATH = $PATH:$HOME/bin:$LUALOCKS_HOME/bin:$LUA_HOME/bin

4. luajit - luarocks

cd luarocks-3.3.1
# luajit - configure
./configure --prefix=/usr/local/luajit/ \
--with-lua=/usr/local/luajit/ \
--lua-suffix=jit \
--with-lua-include=/usr/local/luajit/include/luajit-2.0 \
--rocks-tree=/usr/local/

# --prefix 设定 luarocks 的安装目录
# --with-lua 则是系统中安装的 lua 的根目录
# --lua-suffix 版本后缀,此处因为openresyt的lua解释器使用的是 luajit, 所以此处得写 jit
# --with-lua-include 设置 lua 引入一些头文件头文件的目录

make && make install

vim ~/.bashrc 
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=$LUAJIT_LIB/include/luajit-2.0

ln -s /usr/local/bin/luarocks /usr/bin/luarocks
# 删除软连接 
# rm /usr/bin/luarocks

# luajit require('cjson')
luarocks install lua-cjson

5. openresty

# Yum Install
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

yum install -y openresty

# Or 编译安装
wget https://openresty.org/download/openresty-1.19.3.1.tar.gz
tar -zxvf openresty-1.19.3.1.tar.gz

# 下载所需插件,如下示例
wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz 
tar -zxvf ngx_cache_purge-2.3.tar.gz # 解压缓存插件, /usr/local/src/ngx_cache_purge-2.3

# 编译 OpenResty
./configure --prefix=/usr/local/openresty --with-luajit --without- 
http_redis2_module --with-http_stub_status_module --with-http_v2_module --with- 
http_gzip_static_module --with-http_sub_module \
--add-module=/usr/local/src/ngx_cache_purge-2.3 # 配置缓存插件的源码路径

# 安装 OpenResty
gmake && gmake install

cd luarocks-3.3.1
# luajit - configure, --prefix 为 OpenResty --prefix - luajit
./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
sudo make install

6. git

yum -y install git

7. node

wget https://nodejs.org/dist/v16.19.1/node-v16.19.1-linux-x64.tar.xz
tar -C /usr/local --strip-components 1 -xJf node-v16.19.1-linux-x64.tar.xz

8. openresty conf

./configure --prefix=/usr/local/openresty/nginx \
--with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include' \
--with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl111/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib' \
--with-cc='ccache gcc -fdiagnostics-color=always' \
--with-pcre-jit \
--with-stream \
--with-stream_ssl_module -\
-with-stream_ssl_preread_module \
--with-http_v2_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_secure_link_module \
--with-http_random_index_module \
--with-http_gzip_static_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-threads \
--with-compat \
--with-stream \
--with-http_ssl_module \
--add-module=../ngx_devel_kit-0.3.1 \
--add-module=../echo-nginx-module-0.62 \
--add-module=../xss-nginx-module-0.06 \
--add-module=../ngx_coolkit-0.2 \
--add-module=../set-misc-nginx-module-0.33 \
--add-module=../form-input-nginx-module-0.12 \
--add-module=../encrypted-session-nginx-module-0.09 \
--add-module=../srcache-nginx-module-0.32 \
--add-module=../ngx_lua-0.10.21 \
--add-module=../ngx_lua_upstream-0.07 \
--add-module=../headers-more-nginx-module-0.33 \
--add-module=../array-var-nginx-module-0.05 \
--add-module=../memc-nginx-module-0.19 \
--add-module=../redis2-nginx-module-0.15 \
--add-module=../redis-nginx-module-0.3.9 \
--add-module=../ngx_stream_lua-0.0.11 \

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:

相关文章

  • 关于opensips用户认证配置文件 opensips.cfg 使用介绍

    关于opensips用户认证配置文件 opensips.cfg 使用介绍

    本篇文章小编为大家介绍,关于opensips用户认证配置文件opensips.cfg使用介绍。需要的朋友参考下
    2013-04-04
  • Linux中FTP账号无法删除文件夹的解决方案

    Linux中FTP账号无法删除文件夹的解决方案

    本篇文章主要给大家分享了Linux中FTP账号无法删除文件夹的解决方案以及原因探索,有兴趣的朋友学习下吧。
    2018-01-01
  • 通过yum升级CentOS/RHEL最小化安装的方法

    通过yum升级CentOS/RHEL最小化安装的方法

    下面小编就为大家带来一篇通过yum升级CentOS/RHEL最小化安装的方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2016-12-12
  • CentOS7防火墙和端口相关命令介绍

    CentOS7防火墙和端口相关命令介绍

    大家好,本篇文章主要讲的是CentOS7防火墙和端口相关命令介绍,感兴趣的同学赶快来看一看吧,对你有帮助的话记得收藏一下,方便下次浏览
    2022-01-01
  • Linux之信号的保存方式

    Linux之信号的保存方式

    这篇文章主要介绍了Linux之信号的保存方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2024-02-02
  • linux查看服务器开放的端口和启用的端口多种方式

    linux查看服务器开放的端口和启用的端口多种方式

    Nmap可以扫描网络中的处于活动状态的主机、开放端口、操作系统版本和服务检测以及执行隐匿方式的信息扫描,这篇文章主要介绍了linux查看服务器开放的端口和启用的端口五种方式,需要的朋友可以参考下
    2022-08-08
  • Linux 检测服务器是否连接着网络

    Linux 检测服务器是否连接着网络

    这篇文章主要介绍了Linux 检测服务器是否连接着网络的相关资料,需要的朋友可以参考下
    2017-05-05
  • SSH远程登录和端口转发详解

    SSH远程登录和端口转发详解

    这篇文章主要介绍了关于SSH远程登录和端口转发的相关资料,文中介绍的非常详细,需要的朋友可以参考借鉴,下面来一起看看吧。
    2017-03-03
  • Nagios的安装与使用详细教程

    Nagios的安装与使用详细教程

    Nagios是一款开源的电脑系统和网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等,接下来通过本文给大家介绍Nagios的安装与使用详细教程,需要的朋友参考下
    2016-02-02
  • Linux find命令如何根据时间筛选出文件进行删除

    Linux find命令如何根据时间筛选出文件进行删除

    这篇文章主要介绍了Linux find命令如何根据时间筛选出文件进行删除的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2025-07-07

最新评论