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
相关推荐
虚无的纽扣19 分钟前
【Linux】进程第二课:进程优先级和环境变量
linux·运维·服务器
maosheng114631 分钟前
【无标题】linux中企业容易考的的小知识点1(rhcsa)
linux·运维·服务器
牢姐与蒯36 分钟前
Linux进程(九).自定义shell——深度理解命令行和shell
linux·运维·服务器
snow@li42 分钟前
服务器运维:mysql 安装笔记
运维·服务器·mysql
天道jimmy1 小时前
VulnHub 系列:View2aKill,1
linux·运维·服务器
荀彧原名苟或1 小时前
SAP 执行 CMD命令(GUI_EXEC 执行电脑本机命令、SXPG_COMMAND_EXECUTE函数执行服务器上的外部程序)<转载>
运维·服务器·sap·abap
帷幕落秋1 小时前
Nginx 系列实战(三):LNMP 完整搭建,动静分离的学习总结
运维·自动化运维
Jae den1 小时前
服务器 CPU 核心越多越好吗?
运维·服务器
先吃饱再说1 小时前
从本地跑通到公网访问:前后端项目部署实战
运维·全栈
帷幕落秋1 小时前
一文吃透 Nginx 虚拟主机:原理 + 双站点实战 + SELinux 排错
运维·自动化运维