nginx动态添加扩展模块

说明

已经安装好的nginx,需要添加一个未被编译安装的模块,需要怎么做呢?

具体

这里以安装第三方echo-nginx-module模块为例
用于nginx配置文件变量输出,方便查看配置信息=

nginx的模块是需要重新编译nginx,而不是像Apache一样配置文件引入(.so)

下载第三方扩展模块echo-nginx-module(解压到指定文件夹,随后编译时会路径指向)

# cd /root/Downloads/ 
# wget  https://github.com/openresty/echo-nginx-module/archive/v0.60.tar.gz
# tar zxvf v0.60.tar.gz

查看nginx之前编译安装时安装了哪些模块

[root@hrtask Downloads]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/0.8.50
built by gcc 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) 
TLS SNI support enabled
configure arguments: --user=root --group=root --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_addition_module --with-openssl=/root/Downloads/openssl-1.0.1c --with-pcre=/root/Downloads/pcre-8.20 --with-zlib=/root/Downloads/zlib-1.2.3 

可以看出编译安装使用了

--user=root --group=root --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_addition_module --with-openssl=/root/Downloads/openssl-1.0.1c --with-pcre=/root/Downloads/pcre-8.20 --with-zlib=/root/Downloads/zlib-1.2.3

这里需新增模块,在编译脚本后添加一句:

--add-module=/root/Downloads/echo-nginx-module-0.60

变为:

./configure --user=root --group=root --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_addition_module --with-openssl=/root/Downloads/openssl-1.0.1c --with-pcre=/root/Downloads/pcre-8.20 --with-zlib=/root/Downloads/zlib-1.2.3 --add-module=/root/Downloads/echo-nginx-module-0.60

重新编译

#make

千万不要make install,不然就真的覆盖了 (这里不可make install 会覆盖之前nginx所有配置文件)

首先备份之前的nginx二进制文件,然后替换

若nginx服务启动需关闭 否则nginx复制会报错

# cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
# cp ./objs/nginx /usr/local/nginx/sbin/

搞定~

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值