首先查看一下当初安装nginx时添加的模块
[root@client1 nginx-1.15.9]# nginx -V nginx version: nginx/1.15.9 built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx
然后切换到当初nginx安装包的解压路径,编译时注意重新修改所需模块,最后执行make即可,无需执行make install
[root@client1 nginx-1.15.9]# cd /usr/src/nginx-1.15.9/ [root@client1 nginx-1.15.9]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module && make
如果安装过程中有报错的话,可能是缺少必要依赖包。可以安装模块所需的依赖包进行解决下,常见的依赖安装包有
pcre-devel zlib-devel openssl-devel
将原先的nginx命令备份一下
[root@client1 nginx-1.15.9]# cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
然后将解压包中的命令copy一份过去,注意需要关闭nginx进程,否则会报错“文本文件忙”;
[root@client1 nginx-1.15.9]# cp /usr/src/nginx-1.15.9/objs/nginx /usr/local/nginx/sbin/nginx
然后查看所支持nginx模块
[root@client1 nginx-1.15.9]# nginx -V nginx version: nginx/1.15.9 built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module