Nginx 重新编译添加新的模块

编译安装Nginx的时候,有些模块默认并不会安装,比如http_ssl_module,那么为了让Nginx支持HTTPS,必须添加这个模块。

下面讲解如何在已经安装过后再次添加新的模块。

1、找到安装nginx的源码根目录(即安装包存放目录),如果没有的话下载新的源码并解压

cd software

ls

nginx-1.10.2 nginx-1.10.2.tar.gz

2、查看nginx版本极其编译参数

/usr/local/nginx/sbin/nginx -V

3、进入nginx源码目录

cd nginx-1.10.2

4、重新编译的代码和模块

./configure --prefix=/usr/local/nginx --with-http_ssl_module

5、执行make(注意:千万别make install,否则就覆盖安装了), make完之后在/software/nginx-1.10.2/objs目录下就多了个nginx,这个就是新版本的程序了。
6、备份旧的nginx程序

cd /usr/local/nginx/sbin/

mv nginx nginx_bak

7、把新的nginx程序复制到/usr/local/nginx/sbin/下

cp /software/nginx-1.10.2/objs/nginx /usr/local/nginx/sbin/

8、测试新的nginx程序是否正确

/usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

9、平滑启动服务

/usr/local/nginx/sbin/nginx -s reload

10、查看模块是否已安装

查看ngixn版本极其编译参数

/usr/local/nginx/sbin/nginx -V

nginx version: nginx/1.10.2

built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)

built with OpenSSL 1.0.1e-fips 11 Feb 2013

TLS SNI support enabled

configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module

11、重启Nginx

实践

生产环境安装 http_auth_request_module 模块 使用 auth_request 功能

复制代码
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module  --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module
相关推荐
ESDWAN29 分钟前
SD-WAN 企业选型与落地指南:从链路测试到网络架构设计
运维·网络·架构
啊哈一半醒35 分钟前
Docker 底层知识:从 Namespace 到 UnionFS
运维·docker·容器
_smart_boy__41 分钟前
I.MX6U开发板Uboot无法ping Ubuntu问题解决方案(二)
linux·运维·ubuntu
~光~~1 小时前
【嵌入式Linux学习】GFP_NOIO / GFP_NOFS(Linux 内核 gfp 分配标志)
linux·运维·学习
涵美女程序猿1 小时前
ChatCut online 剪负载均衡健康检查演练录屏:后端池、探针路径与摘除阈值怎样对应
运维·程序人生·电脑·负载均衡
分布式存储与RustFS1 小时前
升级 RustFS 二进制不停机:一条一条换,留一条退路
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
吴声子夜歌2 小时前
Nginx应用与运维——Nginx核心配置指令(一)
运维·nginx
android阿杜2 小时前
Ubuntu 26.04 LTS 系统每次重启后屏幕亮度都会增加一点
linux·运维·ubuntu
路溪非溪3 小时前
Linux下Shell脚本基础知识(二)
linux·运维·服务器
fruge3 小时前
飞牛OS部署Flare导航页:Docker Compose、YAML书签配置与cpolar公网访问
运维·docker·容器