前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >已安装的nginx如何添加模块

已安装的nginx如何添加模块

作者头像
菲宇
发布2019-06-12 16:38:27
11.2K0
发布2019-06-12 16:38:27
举报
文章被收录于专栏:菲宇菲宇

已经安装好的nginx,需要添加一个未被编译安装的模块,需要如何操作呢?

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

代码语言:javascript
复制
# cd /data/software/ 
# git clone https://github.com/cuber/ngx_http_google_filter_module

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

代码语言:javascript
复制
# nginx -V nginx version: nginx/1.15.3
built by gcc 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)
built with OpenSSL 1.1.0f  25 May 2017
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
代码语言:javascript
复制
可以看出编译安装使用了--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

代码语言:javascript
复制
# ./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二进制文件:

代码语言:javascript
复制
# cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
# cp ./objs/nginx /usr/local/nginx/sbin/
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年09月22日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档