Nginx从入门到实战(八):版本平滑无感知,不停机升级

一、查看旧版本信息
可以通过nginx -V命令,来查看当前nginx的版本信息,和配置参数。
[root@nb001 sbin]# nginx -V
-bash: nginx: command not found
[root@nb001 sbin]# ./nginx -V
nginx version: nginx/1.20.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --with-http_stub_status_module --with-http_ssl_module
旧版本的sbin目录情况:
[root@nb001 sbin]# ls -lrth
total 14M
-rwxr-xr-x 1 root root 3.8M Nov 1 2021 nginx.old.1
-rwxr-xr-x 1 root root 3.8M Nov 1 2021 nginx.2021年11月3日17:35:42
-rwxr-xr-x 1 root root 5.8M Nov 3 2021 nginx
二、升级
2.1 下载解压最新安装包
点击下载nginx,这里一般是要下载稳定版。如图:

2.2 上传解压
[root@nb001 softs]# tar -zxvf nginx-1.26.2.tar.gz
nginx-1.26.2/
nginx-1.26.2/man/
。。。
[root@nb001 nginx-1.26.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
2.3 执行编译
首先执行./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
这个命令的参数和之前版本的保持一致即可
[root@nb001 nginx-1.26.2]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
checking for OS+ Linux 3.10.0-1127.19.1.el7.x86_64 x86_64
checking for C compiler ... found+ using GNU C compiler+ gcc version: 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
checking for gcc -pipe switch ... found
。。。省略。。。
checking for zlib library ... found
creating objs/MakefileConfiguration summary+ using system PCRE library+ using system OpenSSL library+ using system zlib librarynginx path prefix: "/usr/local/nginx"nginx binary file: "/usr/local/nginx/sbin/nginx"nginx modules path: "/usr/local/nginx/modules"nginx configuration prefix: "/usr/local/nginx/conf"nginx configuration file: "/usr/local/nginx/conf/nginx.conf"nginx pid file: "/usr/local/nginx/logs/nginx.pid"nginx error log file: "/usr/local/nginx/logs/error.log"nginx http access log file: "/usr/local/nginx/logs/access.log"nginx http client request body temporary files: "client_body_temp"nginx http proxy temporary files: "proxy_temp"nginx http fastcgi temporary files: "fastcgi_temp"nginx http uwsgi temporary files: "uwsgi_temp"nginx http scgi temporary files: "scgi_temp"[root@nb001 nginx-1.26.2]#
执行成功后,接着执行make命令:
[root@nb001 nginx-1.26.2]# make
make -f objs/Makefile
make[1]: Entering directory `/data/softs/nginx-1.26.2'
。。。省略。。。
objs/src/http/modules/ngx_http_stub_status_module.o \
objs/ngx_modules.o \
-ldl -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lpthread -lz \
-Wl,-E
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \-e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \-e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \-e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/data/softs/nginx-1.26.2'
执行完make命令之后,可以发现在objs目录下生成了nginx文件
[root@nb001 nginx-1.26.2]# cd objs/
[root@nb001 objs]# ls
autoconf.err Makefile nginx nginx.8 ngx_auto_config.h ngx_auto_headers.h ngx_modules.c ngx_modules.o src
最后,执行make install,这里install命令都是会看是否存在的,不存在执行安装,存在就不执行对应的复制步骤了。一般可以放心执行。当然如不放心,可以手动复制处理。在此建议备份后(如conf文件,sbin文件,甚至html文件)再执行。
[root@nb001 nginx-1.26.2]# make install
make -f objs/Makefile install
make[1]: Entering directory `/data/softs/nginx-1.26.2'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' \|| mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \|| mv '/usr/local/nginx/sbin/nginx' \'/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' \|| mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types' \|| cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params' \|| cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params \'/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf' \|| cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params' \|| cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params \'/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params' \|| cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params \'/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf' \|| cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' \|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' \|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \|| cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \|| mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/data/softs/nginx-1.26.2'
[root@nb001 nginx-1.26.2]#
去看sbin目录,和旧版本的sbin目录对比发现:上一个nginx被命名为nginx.old, 并将最新的nginx复制到了sbin下。
且经过查看conf/nginx.conf没有被覆盖。
[root@nb001 sbin]# ls -lrth
total 25M
-rwxr-xr-x 1 root root 3.8M Nov 1 2021 nginx.old.1
-rwxr-xr-x 1 root root 3.8M Nov 1 2021 nginx.2021年11月3日17:35:42
-rwxr-xr-x 1 root root 5.8M Nov 3 2021 nginx.old
-rwxr-xr-x 1 root root 5.8M Oct 9 09:39 nginx
[root@nb001 sbin]#
三、校验和最后一步
3.1 查看当前运行的nginx
访问发现,目前还是旧版本。这里访问你的ip随便一个路径就行

3.2 最后一步升级操作
需要在新版本目录下执行 make upgrade操作,完成进程更新。
[root@nb001 nginx-1.26.2]# make upgrade
/usr/local/nginx/sbin/nginx -t
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /usr/local/nginx/conf/vhost_cvec/ss-prod.conf:2
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /usr/local/nginx/conf/vhost_cvec/us.conf:10
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
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
sleep 1
test -f /usr/local/nginx/logs/nginx.pid.oldbin
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
[root@nb001 nginx-1.26.2]#
3.3 再次查看当前运行的nginx
访问发现,已经是新版本啦。

至此,实现了nginx版本的平滑无感知,不停机升级 , 有需要的小伙伴快去试试吧。
END
相关文章:
Nginx从入门到实战(八):版本平滑无感知,不停机升级
一、查看旧版本信息 可以通过nginx -V命令,来查看当前nginx的版本信息,和配置参数。 [rootnb001 sbin]# nginx -V -bash: nginx: command not found [rootnb001 sbin]# ./nginx -V nginx version: nginx/1.20.1 built by gcc 4.8.5 20150623 (Red Hat …...
jQuery 用户登录页面非空校验与登录测试
文章目录 实战介绍准备工作创建网页导入样式表和jQuery库编写页面代码编写脚本代码创建成功页面浏览网页和测试结束语 实战介绍 大家好,今天我们将一起学习如何使用jQuery来为用户登录页面进行非空校验和登录测试。通过这个实战项目,你将学会如何通过jQ…...
《Linux从小白到高手》综合应用篇:深入理解Linux进程调优
本篇深入介绍Linux进程调优. 1. Linux系统进程类型: Linux的进程可能有成千上万个: 新建状态:进程刚刚被创建,但尚未运行。 就绪状态:进程已经准备好运行,等待CPU分配。 运行状态࿱…...
Linux安装elasticsearch单机版
下载地址: Download Elasticsearch | Elastic 下载的安装包是elasticsearch-7.12.0-linux-x86_64.tar.gz 解压缩文件 tar -zxvf elasticsearch-7.12.0-linux-x86_64.tar.gz #编辑文件 vim config/elasticsearch.yml# 加入如下配置 # 集群名称,一个…...
el-table表头加红色星标
代码: <el-table-column prop"name" label"姓名" width"auto"><template #header><span style"color: red; margin-right: 4px">*</span><span>姓名</span></template></el…...
2.1 HTML5 - Canvas标签
文章目录 引言Canvas标签概述定义实例:创建画布 理解Canvas坐标系概述实例:获取Canvas坐标 获取Canvas环境上下文概述实例:获取Canvas环境上下文设置渐变色效果 结语 引言 大家好,今天我们要一起探索HTML5中一个非常有趣且强大的…...
T-Box联网安全定义
T-Box,即Telematics BOX,也称远程信息处理控制单元(Telematics Control Unit,TCU),是车联网中的重要组成部分。它集成了GPS、外部通信接口、电子处理单元、微控制器、移动通信单元和存储器等功能模块&#…...
7. 整数反转【数学】
文章目录 7. 整数反转解题思路Go代码 7. 整数反转 7. 整数反转 给你一个 32 位的有符号整数 x ,返回将 x 中的数字部分反转后的结果。 如果反转后整数超过 32 位的有符号整数的范围 [ − 2 31 , 2 31 − 1 ] [−2^{31}, 2^{31} − 1] [−231,231−1] ࿰…...
Windows环境NodeJS下载配置安装运行
Windows环境NodeJS下载配置安装运行 (1)下载 Node.js — Run JavaScript Everywhere 安装文件。 一路傻瓜式安装。 如果安装正常,输入命令可显示版本号: (2)可以查询nodejs默认的后续依赖安装包位置及缓存…...
石化巡检必备神器,AORO A30防爆手机让“跑冒滴漏”无处藏身!
在石油化工企业生产现场,设备种类繁多,巡检项目错综复杂,任何微小的疏忽都可能引发严重的安全事故。遨游通讯推出了AORO A30防爆手机,精准定位细微故障,在源头上有效控制或消除“跑冒滴漏”等安全隐患。 AORO A30防爆手…...
Smartfusion2开发环境的搭建
Libero软件安装包括libero安装、bibero补丁安装、bibero的license添加和官方ip库的添加等4部分内容组成。具体内容如下所示: 1 Libero软件安装 1、解压LiberoSoC_v11.8的安装包到当前目录,然后运行Libero中的可执行软件进行安装; 图1 双击l…...
使用C++编写一个语音播报时钟(Qt)
要求:当系统时间达到输入的时间时,语音播报对话框中的内容。定时可以取消。qt界面如上图所示。组件如下: countdownEdit作为书写目标时间的line_edit start_btn作为开始和停止的按钮 stop_btn作为取消的按钮 systimelab显示系统时间的lab tex…...
架构师之路-学渣到学霸历程-11
权限管理 我们可以通过一下命令来了解Linux的用户权限; Linux的用户权限真的涉及得非常好,让我们了解一下用户权限的知识吧; let’s go go go~! chmod命令: 作用:变更文件或者目录的权限语法:…...
Java Mail腾讯企业邮箱或其他邮箱发送邮件失败bug记录
问题出现情况 邮件发送时debug用F8逐步运行可以成功发送邮件,但是用F9或者直接运行程序却发送失败未开启mail的debug模式的报错日志是下面这个:org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is java…...
【大数据】HBase集群断电文件坏块导致集群无法启动处理
hfile文件有坏块 Corrupt文件目录:/hbase/data/… HBase异常:region无法在正常上线,http://master:16010页面看region 一直处于transition状态 wal文件损坏 Corrupt文件目录:/hbase/oldWALs/…或/hbase/WALs/… HBase异常&…...
400行程序写一个实时操作系统(三):Sparrow的学习方法
千里之行始于足下,为了让大家的学习更加事半功倍,笔者将会介绍RTOS的学习方法。 可能很多人拿到一份源码,就想通过各种方式搞懂它,例如抄代码或者读代码。 笔者认为,单纯抄一个实时操作系统是没有任何用处的。比如对…...
为什么人工智能用 Python?
人工智能领域倾向于使用Python,主要归因于Python的多个显著优势: 简洁性与可读性:Python的语法设计简洁明了,代码易于阅读和理解,这对于涉及复杂算法和逻辑的人工智能项目尤为重要。它降低了编程门槛,使得…...
【C++差分数组】P1672何时运输的饲料
本文涉及知识点 C差分数组 C算法:前缀和、前缀乘积、前缀异或的原理、源码及测试用例 包括课程视频 P1672何时运输的饲料 原文比较啰嗦,我简述一下: 第x天运来F1(1<F1<1e6)千克的饲料,第D(1<2e3)天还剩F2&…...
Go基础知识:切片
数组 Go 数组的大小是固定的,其长度是其类型的一部分([4]int并且[5]int是不同的、不兼容的类型) var a [10]intb : [2]string{"Penn", "Teller"} b : [...]string{"Penn", "Teller"}package maini…...
Redis配置篇 - 指定Redis配置的三种方式,以及Redis配置文件介绍
文章目录 1 指定Redis配置的三种方式1.1 通过命令行参数来指定Redis配置1.2 通过配置文件来指定Redis配置1.3 在服务器运行时更改 Redis 配置 2 关于Redis配置文件 1 指定Redis配置的三种方式 1.1 通过命令行参数来指定Redis配置 在redis启动时,可以直接通过命…...
突破内容采集瓶颈:XHS-Downloader的5大行业解决方案与效率提升指南
突破内容采集瓶颈:XHS-Downloader的5大行业解决方案与效率提升指南 【免费下载链接】XHS-Downloader 小红书(XiaoHongShu、RedNote)链接提取/作品采集工具:提取账号发布、收藏、点赞、专辑作品链接;提取搜索结果作品、…...
从用户视角优化:让QGC地面站的盘旋半径显示更直观的3个实用技巧
从用户视角优化:让QGC地面站的盘旋半径显示更直观的3个实用技巧 在无人机飞行任务规划中,盘旋半径的准确显示直接关系到飞行安全和任务执行效率。QGroundControl(QGC)作为业界领先的开源地面站软件,其功能强大但某些细…...
intv_ai_mk11保姆级教程:如何用supervisorctl诊断服务异常并快速恢复
intv_ai_mk11保姆级教程:如何用supervisorctl诊断服务异常并快速恢复 1. 服务异常诊断的重要性 当你使用intv_ai_mk11文本生成服务时,可能会遇到服务响应慢、无法生成内容或页面无法访问的情况。这些问题的根源可能来自多个方面:模型加载异…...
手把手教你从Docker中提取Milvus二进制文件并配置集群环境
深度解析:从Docker镜像提取Milvus二进制文件的完整实践指南 在向量数据库领域,Milvus凭借其出色的性能和可扩展性已经成为众多AI应用的首选基础设施。虽然官方推荐使用Docker进行部署,但在生产环境中,直接使用二进制文件部署往往…...
终极指南:如何使用Harepacker-resurrected打造个性化MapleStory游戏体验
终极指南:如何使用Harepacker-resurrected打造个性化MapleStory游戏体验 【免费下载链接】Harepacker-resurrected All in one .wz file/map editor for MapleStory game files 项目地址: https://gitcode.com/gh_mirrors/ha/Harepacker-resurrected 你是否曾…...
RIFE智能帧插值技术全解析:从原理到实战的视频流畅度提升指南
RIFE智能帧插值技术全解析:从原理到实战的视频流畅度提升指南 【免费下载链接】video2x A machine learning-based video super resolution and frame interpolation framework. Est. Hack the Valley II, 2018. 项目地址: https://gitcode.com/GitHub_Trending/v…...
终极Redis可视化工具:Another Redis Desktop Manager完全使用指南
终极Redis可视化工具:Another Redis Desktop Manager完全使用指南 【免费下载链接】AnotherRedisDesktopManager 🚀🚀🚀A faster, better and more stable Redis desktop manager [GUI client], compatible with Linux, Windows, …...
SAP Analysis for Office 2.8 SP6 升级与常见问题解决指南
1. SAP Analysis for Office 2.8 SP6升级前的准备工作 升级软件就像给房子做装修,准备工作做得好,后续问题少一半。对于SAP Analysis for Office(简称AFO)2.8 SP6版本升级,我建议先做好这三件事: 第一&…...
Matlab_Simulink与Carsim的联合仿 擅长基于群智能算法优化的LQR、PID控制算法,能清晰讲解其中要点哦。对于基于群智能算法的一般路径规划
Matlab/Simulink与Carsim的联合仿 擅长基于群智能算法优化的LQR、PID控制算法,能清晰讲解其中要点哦。对于基于群智能算法的一般路径规划 稍长智能车轨迹跟踪控制方向 熟悉Matlab/Simulink和Carsim的联合仿真呢。这是一个非常专业且热门的研究方向(群智能…...
ISO/SAE 21434:2021 逐条审核判定表
A 章节号|B 条款|C 要求内容|D 符合性|E 证据 / 说明|F:不符合整改项符合性选项:符合 / 部分符合 / 不符合 / 不适用章节号条款审核要求内容符合性证据 / 备注整改项44.1建立网络安全生命周…...
