日期 版本 作者 说明
2023-06-25 V-1.0 孔留锋 文档新建。

Nginx版本升级

背景

​ 现有版本Nginx 1.18.0 存在已知漏洞。如下:

概述

​ 升级到官网最新稳定版本。

​ 官网地址:http://nginx.org/en/download.html

​ 最新稳定版本:nginx-1.24.0

​ 下载安装包:nginx-1.24.0.tar.gz

升级流程

备份

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#查看现有版本
/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.18.0
built by gcc 8.3.0 (Uos 8.3.0.9-1+eagle)
built with OpenSSL 1.1.1d 10 Sep 2019
TLS SNI support enabled
configure arguments: --with-http_stub_status_module --with-http_ssl_module

#创建备份文件
midir -p /opt/bak/nginx1.18/
#备份配置文件
cp /usr/local/nginx/config/nginx.conf /opt/bak/nginx1.18/
#备份脚本文件
cp /usr/local/nginx/sbin/nginx /opt/bak/nginx1.18/

升级

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#创建
midir -p /opt/software
#上传安装包nginx-1.24.0.tar.gz到该目录下
# 解压
tar -zxvf /opt/software/nginx-1.24.0.tar.gz -C /opt/moudle/
# 切换目录
/opt/moudle/nginx-1.24.0

#停止现有版本
/usr/local/nginx/sbin/nginx -s stop

#安装
##切换目录
/opt/moudle/nginx-1.24.0
##编译
./configure --with-http_stub_status_module --with-http_ssl_module
##安装
make && make install

#查看版本
/usr/local/nginx/sbin# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.24.0
built by gcc 8.3.0 (Uos 8.3.0.9-1+eagle)
built with OpenSSL 1.1.1d 10 Sep 2019
TLS SNI support enabled
configure arguments: --with-http_stub_status_module --with-http_ssl_module