编译nginx平滑添加模块
young / / / 阅读量

操作背景

操作系统版本:CentOS Linux release 7.4.1708 (Core)
nginx版本:1.13.4
以stream模块为例

nginx编译添加stream模块

查看原nginx编译参数

[root@test-server sbin]# nginx -V
nginx version: nginx/1.13.4
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) 
built with OpenSSL 1.1.1  11 Sep 2018
TLS SNI support enabled
configure arguments: --prefix=/web/soft/nginx-8081 --with-openssl=/usr/local/ssl --with-http_stub_status_module --with-http_ssl_module --with-pcre

添加stream模块进行重新编译

此处nginx源码目录为:/usr/local/src/nginx-1.13.4,即为编译命令执行目录。
编译命令如下:

./configure --prefix=/web/soft/nginx-8081 --with-openssl=/usr/local/ssl --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-stream

进行make操作

此处nginx源码目录为:/usr/local/src/nginx-1.13.4,即为编译命令执行目录。
make
此处一定不能使用make install命令,执行该命令会将原有nginx目录进行覆盖。

关停nginx同时复制新的nginx启动文件

关闭nginx服务

systemctl stop nginx

备份原有nginx二进制文件。

cp /web/soft/nginx-8081/sbin/nginx /web/soft/nginx-8081/sbin/nginx-no-strem

复制新编译好的nginx二进制文件。从此处nginx源码目录为:/root/nginx-1.13.4。即为编译命令执行目录。

cp ./objs/nginx /web/soft/nginx-8081/sbin/nginx

启动测试 

启动nginx。

systemctl start nginx

查看nginx模块信息。

nginx -V
nginx version: nginx/1.13.4
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) 
built with OpenSSL 1.1.1  11 Sep 2018
TLS SNI support enabled
configure arguments: --prefix=/web/soft/nginx-8081 --with-openssl=/usr/local/ssl --with-http_stub_status_module --with-http_ssl_module --with-pcre

可以看到stream模块已经编译到nginx内了。

支付宝捐赠
请使用支付宝扫一扫进行捐赠
微信捐赠
请使用微信扫一扫进行赞赏
有 0 篇文章