网站首页 > 编程文章 正文
Nginx动态添加模块
很多时候,我们根据当时的项目情况和业务需求安装完 Nginx 后,后续随着业务的发展,往往会给安装好的 Nginx 添加其他的功能模块。在为 Nginx 添加功能模块时,要求 Nginx 不停机。
这就涉及到如何为已安装的 Nginx 动态添加模块的问题。本文,就和小伙伴们一起探讨如何为已安装的 Nginx 动态添加模块的问题。
为Nginx动态添加模块
这里以安装第三方 ngx_http_google_filter_module 模块为例。Nginx 的模块是需要重新编译 Nginx,而不是像 Apache 一样配置文件引用 .so。
下载扩展
下载第三方扩展模块 ngx_http_google_filter_module
# cd /data/software/
# git clone https://github.com/cuber/ngx_http_google_filter_module
查看安装模块
查看 Nginx 编译安装时安装了哪些模块,将命令行切换到 Nginx 执行程序所在的目录并输入 ./nginx -V,具体如下:
[root@binghe sbin]# ./nginx -V
nginx version: nginx/1.19.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
built with OpenSSL 1.0.2 22 Jan 2015
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx-1.19.1 --with-openssl=/usr/local/src/openssl-1.0.2 --with-pcre=/usr/local/src/pcre-8.37 --with-zlib=/usr/local/src/zlib-1.2.8 --with-http_ssl_module
[root@binghe sbin]#
可以看出编译安装 Nginx 使用的参数如下:
--prefix=/usr/local/nginx-1.19.1 --with-openssl=/usr/local/src/openssl-1.0.2 --with-pcre=/usr/local/src/pcre-8.37 --with-zlib=/usr/local/src/zlib-1.2.8 --with-http_ssl_module
重新编译
加入需要安装的模块,重新编译,这里添加 --add-module=/data/software/ngx_http_google_filter_module,具体如下:
./configure --prefix=/usr/local/nginx-1.19.1 --with-openssl=/usr/local/src/openssl-1.0.2 --with-pcre=/usr/local/src/pcre-8.37 --with-zlib=/usr/local/src/zlib-1.2.8 --with-http_ssl_module -–add-module=/data/software/ngx_http_google_filter_module
如上,将之前安装Nginx的参数全部加上,最后添加 --add-module=/data/software/ngx_http_google_filter_module,之后,我们要进行编译操作,如下:
# make //千万不要make install,不然就真的覆盖
这里,需要注意的是:不要执行 make install 命令。
替换nginx二进制文件
# 备份原来的nginx执行程序
# mv /usr/local/nginx-1.19.1/sbin/nginx /usr/local/nginx-1.19.1/sbin/nginx.bak
# 将新编译的nginx执行程序复制到/usr/local/nginx-1.19.1/sbin/目录下
# cp /opt/nginx/sbin/nginx /usr/local/nginx-1.19.1/sbin/
猜你喜欢
- 2024-10-19 基于openssl 实现https服务(基于openssl+实现https服务体系)
- 2024-10-19 Centos openssl 升级方法(centos6.9升级openssh)
- 2024-10-19 OpenSSL神器大揭秘:加密、签名、验证一步搞定!
- 2024-10-19 Openssh8.0升级(openssh8.6p1 升级)
- 2024-10-19 windows使用openssl生成公钥和私钥
- 2024-10-19 Linux服务器运维必备技能 软件包和启动项超详细整理
- 2024-10-19 「应用安全」支持github算法限制,升级git客户端为TSL1.2协议
- 2024-10-19 CentOS 7 升级 openssl(centos7.6升级openssh)
- 2024-10-19 CentOS7下rpm包方式升级openssl到安全版本1.1.1n
- 2024-10-19 源码升级openssl3.2和openssh9.5(openssh软件源)
你 发表评论:
欢迎- 05-142014年最流行前端开发框架对比评测
- 05-14七爪源码:如何使用 Next.js 构建 Shopify 店面
- 05-14Web 前端怎样入门?
- 05-14我为什么不建议你使用框架
- 05-14推荐几个好用的React UI 框架
- 05-14PDFsharp:强大的 .NET 跨平台 PDF 处理库
- 05-14一组开源免费的Web动画图标,荐给需要的设计师和程序员
- 05-14salesforce 零基础学习(二十九)Record Types简单介绍
- 最近发表
- 标签列表
-
- spire.doc (59)
- system.data.oracleclient (61)
- 按键小精灵源码提取 (66)
- pyqt5designer教程 (65)
- 联想刷bios工具 (66)
- c#源码 (64)
- graphics.h头文件 (62)
- mysqldump下载 (66)
- sqljdbc4.jar下载 (56)
- libmp3lame (60)
- maven3.3.9 (63)
- 二调符号库 (57)
- 苹果ios字体下载 (56)
- git.exe下载 (68)
- diskgenius_winpe (72)
- pythoncrc16 (57)
- solidworks宏文件下载 (59)
- qt帮助文档中文版 (73)
- satacontroller (66)
- hgcad (64)
- bootimg.exe (69)
- android-gif-drawable (62)
- axure9元件库免费下载 (57)
- libmysqlclient.so.18 (58)
- springbootdemo (64)
本文暂时没有评论,来添加一个吧(●'◡'●)