nginx漏洞补丁升级
1、安装patch
patch未找到命令,请先下载patch-2.7.6.tar.gz。下载路径:https://mirrors.aliyun.com/gnu/patch/
# 解压
tar -zxf patch-2.7.6.tar.gz
# 编译、检查并安装 Patch
time { ./configure --prefix=/usr && make && make check && make install;}
# 安装完成后清理工作
cd ..
rm -rf patch-2.7.6
2、nginx补丁升级
补丁下载地址:http://nginx.org/download/patch.2022.mp4.txt
2.1 执行补丁
把补丁patch.2022.mp4.txt文件移动到nginx的源码目录下,在nginx的源码目录执行以下命令
patch -p0 < patch.2022.mp4.txt
到nginx安装目录的启动目录,查看之前的安装信息
cd /usr/local/nginx/sbin
./nginx -V
显示如下:
nginx version: nginx/1.21.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.1.1w 11 Sep 2023
TLS SNI support enabled
configure arguments: --prefix=/app/nginx/nginx --with-http_ssl_module --with-openssl=../openssl-1.1.1w
复制nfigure arguments: 后的所有参数,然后在nginx源码目录重新执行编译(注意不能加上install,否则会覆盖原有程序
)
cd /home/fullmark/nginx-1.21.0 && ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=../openssl-1.1.1w && make
2.2 将nginx打完补丁后的nginx文件移到到安装目录下的sbin下
# 先备份
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
# 把打完补丁的nginx移到到安装目录下(如果无法覆盖,先停止nginx)
cp /home/fullmark/nginx-1.21.0/objs/nginx /usr/local/nginx/sbin/
3、nginx启动,停止,重启命令
# 停止nginx
pkill nginx
# 启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
# 重启
/usr/local/nginx/sbin/nginx -s reload