Nginx添加新模块&平滑重启

需求

当编译完成后的Nginx需要添加新的模块时,我们需要添加该模块重新编译。

比如我这里的需求是:编译好Nginx后,我需要添加nginx-rtmp-module模块

环境

[系统环境:CentOS release 6.7 (Final) nginx/1.8.1]

nginx的安装位置:/opt/nginx 
nginx软件包位置:/opt/software/nginx-1.8.1

准备

下载新模块

下载需要添加的模块:nginx-rtmp-module

git clone https://github.com/arut/nginx-rtmp-module.git

放至指定位置:

mv nginx-rtmp-module /opt/software/nginx-1.8.1/modules

 

查看已编译的参数

/opt/nginx/sbin/nginx -V
configure arguments: --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre=/opt/software/pcre-8.35 --with-zlib=/opt/software/zlib-1.2.8 --with-openssl=/opt/software/openssl-1.0.1i

重新编译

带上新模块重新编译

使用上一步查询到的编译参数,带上–add-module=path_of_new_module

cd /opt/software/nginx-1.8.1
./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre=/opt/software/pcre-8.35 --with-zlib=/opt/software/zlib-1.2.8 --with-openssl=/opt/software/openssl-1.0.1i --add-module=/opt/software/nginx-1.8.1/modules/nginx-rtmp-module
make

注意:这里只有make,一定不要手贱顺手执行了make install,不然会覆盖安装的

平滑重启

上一步执行完成后,会在当前目录下生成objs目录,其中的nginx文件即为新的二进制文件

备份原文件

cp /opt/nginx/sbin/nginx /opt/nginx/sbin/nginx.bak

替换nginx二进制文件

cp -f /opt/software/nginx-1.8.1/objs/nginx /opt/nginx/sbin/nginx

正确性检查

/opt/nginx/sbin/nginx -t

这里写图片描述

reload Nginx

/opt/nginx/sbin/nginx -s reload

检查nginx进程是否启动

查看编译结果

/opt/nginx/sbin/nginx -V

Done!

 

原文地址:https://blog.csdn.net/loyachen/article/details/50902667

posted on   咚..咚  阅读(176)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示