背景:漏洞扫描nginx漏洞,查看版本为1.16.1,打算升级到1.22.0
两台nginx服务器上安装了fastdfs,nginx为fastdfs服务,所以要注意预编译参数
1、备份nginx.conf
cp /usr/local/nginx/conf/nginx.conf /root/
2、下载nginx1.22安装包
3、移动
mv /usr/local/src/nginx-1.22.0.tar.gz /usr/local/mv /usr/local/src/nginx-1.22.0.tar.gz /usr/local/
4、解压
cd /usr/local/
tar -xvf nginx-1.22.0.tar.gz
5、
nginx -V
6、预编译
./configure --with-http_ssl_module \
--with-http_v2_module --with-http_realip_module --with-http_stub_status_module \
--with-http_secure_link_module --with-stream --with-stream_ssl_module \
--with-stream_realip_module --add-module=/opt/fastdfs_pkg/fastdfs-nginx-module/src --with-openssl=/usr/local/src/openssl-3.0.5
7、make编译 ————注意:此处不用 make install!!!
make
8、将新版的nginx程序拷贝到旧版目录下
cp -f /usr/local/nginx-1.22.0/objs/nginx /usr/local/nginx/sbin/nginx
ps aux | grep nginx #查看进程
找到nginx父进程的pid号,发送USR2信号
依次执行命令
kill -USR2 1848
kill -WINCH 1848
kill -QUIT 1848
9、查看版本
[root@vdl-e-business-chengminmiao-5 ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.22.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 3.0.5 5 Jul 2022
TLS SNI support enabled
configure arguments: --with-http_ssl_module --with-http_v2_module
--with-http_realip_module --with-http_stub_status_module
--with-http_secure_link_module --with-stream
--with-stream_ssl_module --with-stream_realip_module
--add-module=/opt/fastdfs_pkg/fastdfs-nginx-module/src -
-with-openssl=/usr/local/src/openssl-3.0.5 #旧版本的没有这行,但是不加会报错,看情况