架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 11722|回复: 2

[Web] 【实战】已安装nginx动态添加模块

[复制链接]
发表于 2016-12-7 13:39:50 | 显示全部楼层 |阅读模式
说明:
已经安装好的nginx,需要添加一个未被编译安装的模块,需要怎么弄呢?

具体:
这里以安装第三方ngx_http_google_filter_module模块为例
nginx的模块是需要重新编译nginx,而不是像apache一样配置文件引用.so
1. 下载第三方扩展模块ngx_http_google_filter_module

# cd /data/software/
# git clone https://github.com/cuber/ngx_http_google_filter_module

2. 查看nginx编译安装时安装了哪些模块

# nginx -V
nginx version: nginx/1.8.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/data/software/ngx_http_substitutions_filter_module

可以看出编译安装使用了--prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/data/software/ngx_http_substitutions_filter_module这些参数。--add-module=/data/software/ngx_http_substitutions_filter_module是之前编译添加ngx_http_substitutions_filter_module模块时添加

3. 加入需要安装的模块,重新编译,如这里添加–add-module=/data/software/ngx_http_google_filter_module

# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/data/software/ngx_http_substitutions_filter_module --add-module=/data/software/ngx_http_google_filter_module
# make    //千万不要make install,不然就真的覆盖了

4. 替换nginx二进制文件:

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

# cp ./objs/nginx /usr/local/nginx/sbin/
QQ截图20161207132412.jpg
(注意,执行这句话的时候,可能会出错,cp: cannot create regular file `/service/nginx-1.10.2/sbin/nginx': Text file busy,原因是nginx文件,还在使用中,在重新添加模块的时候,最好,先停止nginx!!!)






上一篇:nginx: [error] open() /nginx.pid failed (2: No such file or directory)
下一篇:nginx设置代理缓存
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2018-4-27 10:18:10 | 显示全部楼层
nginx添加第三方模块,以及启用nginx本身支持的模块
http://www.itsvse.com/thread-4713-1-1.html
(出处: 架构师_程序员)
参考文章
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
发表于 2019-6-2 00:54:39 | 显示全部楼层
谢谢分享
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2024-4-20 05:41

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表