Nginx之为已安装nginx动态添加模块的方法

发布时间:2025-11-10 点击:23
服务器
说明:
已经安装好的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_module2. 查看nginx编译安装时安装了哪些模块
# nginx -vnginx version: nginx/1.8.0built by gcc 4.4.7 20120313 (red hat 4.4.7-11) (gcc) built with openssl 1.0.1e-fips 11 feb 2013tls sni support enabledconfigure 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/以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持西部数码。

现如今的域名为何如此重要?域名的使用出自什么原因?
个人域名可以注册cn域名吗?怎么注册
阿里云 云服务器价格
过期未注册域名查询方法 怎么查询过期未注册域名
京东云亮相2019数据中心年度峰会,智能IDC业务为数据时代加速
构建DHCP服务及原理,设置专门的网址
什么是企业域名和个人域名?企业域名和个人域名的区别是什么
网站打不开文件处理好了隔些时间有打不开