nginx安装LUA模块

nginx安装LUA模块

nginx上面一共需要安装3个东西:luajit,ngx_devel_kit,lua-nginx-module
注:在nginx上对gzip数据进行解压需要使用lua
参考文献:https://blog.csdn.net/qq_27156945/article/details/104019069

下载安装LuaJIT-2.0.4.tar.gz:
#wget -c http://luajit.org/download/LuaJIT-2.0.4.tar.gz
#tar xzvf LuaJIT-2.0.4.tar.gz
#cd LuaJIT-2.0.4
#make && make install PREFIX=/usr/local/luajit  #安装路径可以自定义
................
==== Successfully installed LuaJIT 2.0.4 to /usr/local/luajit ====  ###安装成功

配置环境变量
#vim /etc/profile
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
#source /etc/profile
#cp /usr/local/luajit/lib/libluajit-5.1.so.2 /usr/local/lib/
#echo "/usr/local/lib"  >>/etc/ld.so.conf
#/sbin/ldconfig

下载解压ngx_devel_kit
#cd /data/softs/
#wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
#tar -xzvf v0.3.0.tar.gz

下载解压lua-nginx-module
#wget https://github.com/openresty/lua-nginx-module/archive/v0.10.9rc7.tar.gz
#tar -xzvf v0.10.9rc7.tar.gz

nginx第三方模块安装:
查看已安装模块:
[root@lwyd ~]# /data/softs/nginx/sbin/nginx -V
........................
nginx version: nginx/1.18.0
............................
configure arguments: --prefix=/data/softs/nginx --user=root --group=root --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_dav_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-threads --with-file-aio --add-module=./modules/ngx_http_upstream_check_module 

下载对应版本ng
cd /data/softs/ && wget https://nginx.org/download/nginx-1.18.0.tar.gz
tar -xvf nginx-1.18.0.tar.gz
cd /data/softs/nginx-1.18.0
./configure --prefix=/data/softs/nginx --user=root --group=root --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_dav_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-threads --with-file-aio --add-module=/data/softs/nginx_upstream_check_module --add-module=/data/softs/lua-nginx-module-0.10.9rc7 --add-module=/data/softs/ngx_devel_kit-0.3.0
注:
##新增编译模块  --add-module=/data/softs/lua-nginx-module-0.10.9rc7 --add-module=/data/softs/ngx_devel_kit-0.3.0
##如果./configure报错./configure: error: no ./modules/ngx_http_upstream_check_module/config was found 请看下面的处理方式

make

#备份旧的nginx可执行文件
cp -rf /data/softs/nginx/sbin/nginx /data/softs/nginx/sbin/nginx.bak
#使用新的
cp -rf /data/softs/nginx-1.18.0/objs/nginx /data/softs/nginx/sbin/nginx

重启nginx生效
killall nginx
/data/softs/nginx/sbin/nginx
###############################################  ./configure无报错可以忽略此处
#以前的源码包可能被清理,以前编译的ngx_http_upstream_check_module目录是在源码目录下(--add-module=./modules/ngx_http_upstream_check_module),报错如下:
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
configuring additional modules
adding module in ./modules/ngx_http_upstream_check_module
./configure: error: no ./modules/ngx_http_upstream_check_module/config was found

解决方式:
./configure --prefix 报错 找不到nginx_upstream_check_module模块 --add-module=/data/softs/upstream_check_module-master/
自定义安装:
cd /data/softs
#下载nginx_upstream_check_module
wget https://codeload.github.com/yaoweibin/nginx_upstream_check_module/zip/master
#解压
unzip master
mv nginx_upstream_check_module-master   nginx_upstream_check_module  
cd nginx_upstream_check_module/
#安装patch
yum install patch -y
# 加载小于或等于nginx版本的check
cd 进入nginx的源码包目录,不是在nginx的安装目录下,没有源码包就去官网下载一个相同版本的
cd /data/softs/nginx-1.18.0
[root@lwyd nginx-1.18.0]#  patch -p1 < /data/softs/nginx_upstream_check_module/check_1.16.1+.patch
patching file src/http/modules/ngx_http_upstream_hash_module.c
patching file src/http/modules/ngx_http_upstream_ip_hash_module.c
patching file src/http/modules/ngx_http_upstream_least_conn_module.c
patching file src/http/ngx_http_upstream_round_robin.c
patching file src/http/ngx_http_upstream_round_robin.h
[root@lwyd nginx-1.18.0]# echo $?
0
重新编译:
make clean all

./configure --prefix=/data/softs/nginx --user=root --group=root --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_dav_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-threads --with-file-aio --add-module=/data/softs/nginx_upstream_check_module --add-module=/data/softs/lua-nginx-module-0.10.9rc7 --add-module=/data/softs/ngx_devel_kit-0.3.0

make
  • 5
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值