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.202111317: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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/55945.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C/C++语言基础--C++神奇的多态

本专栏目的 更新C/C的基础语法&#xff0c;包括C的一些新特性 前言 通过前面几节课&#xff0c;我们学习了抽象、封装、继承相关的概念&#xff0c;接下来我们将讲解多态&#xff0c;多态他非常神奇&#xff0c;正式有了他&#xff0c;类才能出现多样性特征&#xff1b;C语言…

【C++差分数组】P1672何时运输的饲料

本文涉及知识点 C差分数组 C算法&#xff1a;前缀和、前缀乘积、前缀异或的原理、源码及测试用例 包括课程视频 P1672何时运输的饲料 原文比较啰嗦&#xff0c;我简述一下&#xff1a; 第x天运来F1(1<F1<1e6)千克的饲料&#xff0c;第D&#xff08;1<2e3)天还剩F2&…

DBA | 如何将 .mdf 与 .ldf 的数据库文件导入到SQL Server 数据库中?

[ 知识是人生的灯塔&#xff0c;只有不断学习&#xff0c;才能照亮前行的道路 ] 原文链接&#xff1a;DBA | 如何将 .mdf 与 .ldf 的数据库文件导入到SQL Server 数据库中? 如何将 (.mdf) 和 (.ldf) 的SQL Server 数据库文件导入到当前数据库中? Step 1.登录到 Sql Server 服…

【Nginx系列】Nginx启动失败

&#x1f49d;&#x1f49d;&#x1f49d;欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学…

Java笔记Day42:初入六六村!(springMVC前后端不同数据类型传值)

1.前端传参方式: 1.url传参&#xff1a; 数据参数直接写在url地址中&#xff0c;一般使用get请求。 使用params传输的就是url类型的参数&#xff1b; &#xff08;params 参数通常用于发送 URL 查询参数。 这些参数会附加到请求的 URL 中&#xff0c; 并以 keyvalue 的形…

数学建模算法与应用 第12章 现代优化算法

目录 12.1 粒子群优化算法 Matlab代码示例&#xff1a;粒子群优化算法求解函数最小值 12.2 遗传算法 Matlab代码示例&#xff1a;遗传算法求解函数最小值 12.3 蚁群算法 Matlab代码示例&#xff1a;蚁群算法求解旅行商问题 12.4 Matlab 遗传算法工具 使用遗传算法工具箱…

docker overlay 占用空间太大,迁移到 /data/

将 Docker 的 overlay 存储驱动迁移到 /data/ 目录下&#xff0c;可以通过以下步骤完成&#xff1a; 1. 停止 Docker 服务 首先&#xff0c;停止 Docker 服务以确保没有容器在运行&#xff0c;并且数据不会被写入到当前的存储位置。 sudo systemctl stop docker2. 备份现有数…

PyCharm打开及配置现有工程(详细图解)

本文详细介绍了如何利用Pycharm打开一个现有的工程&#xff0c;其中包括编译器的配置。 PyCharm打开及配置现有工程 1、打开工程2、配置编译器 1、打开工程 双击PyCharm软件&#xff0c;点击左上角 文件 >> 打开(O)… 选中想要打开的项目之后点击“确定” 2、配置编译器…

余承东直播论道智能驾驶:激光雷达不可或缺,华为ADS 3.0引领安全创新

华为余承东:激光雷达,智能驾驶安全性的关键 9月29日,华为消费者业务集团CEO余承东在一场引人注目的直播中,与知名主持人马东就智能驾驶技术的最新进展进行了深入交流。在这场直播中,余承东针对激光雷达在智能驾驶中的必要性问题,发表了明确且深刻的观点,引发了业界和公众…

报错 - llama-index pydantic error | arbitrary_types_allowed | PydanticUserError

国庆节前使用 LiteLLMEmbedding 设置 llama-index Settings.embed_model 还好好的&#xff0c;回来后&#xff0c;就就报错&#xff0c;试着降级 llama-index 也无用&#xff1b;设置 Settings.llm 也是好好地。 解决方法&#xff1a;conda 重新创建环境后&#xff0c;在安装 …

uniapp自定义导航,全端兼容

我们在用uniapp 开发应用的时候&#xff0c;有的页面需要自定义导航&#xff0c; 1.如果普通的直接使用uni 扩展柜组件的 uni-nav-bar 也基本够用&#xff0c; 2.如果稍微带点自定义的这个值无法支持的&#xff0c;特别在小程序端&#xff0c;胶囊是会压住右边的按钮的 自定…

小白必看web专题!PHP-WebShell免杀(基础版)!!真的很简单!(全网最详细版本)

大家好&#xff0c;我是Dest1ny&#xff01; 最近一直在搞辅导啥的&#xff0c;所以没啥时间搞写&#xff5e; 也谢谢大家一直的点赞&#xff0c;今天特意把之前的web专题再发一个。 废话不多说&#xff0c;我们直接开始&#xff01; CLASS-1 WebShell免杀测试 渊龙Sec团队导…

PyQt5常用功能三

日历 QCalendarWidget 提供了基于⽉份的⽇历插件&#xff0c;⼗分简易⽽且直观 from PyQt5.QtWidgets import (QWidget, QCalendarWidget,QLabel, QApplication, QVBoxLayout) from PyQt5.QtCore import QDate import sysclass Example(QWidget):def __init__(self):super().…

[C#]项目中如何用 GraphQL 代替传统 WebAPI服务

在现代应用程序开发中&#xff0c;传统的 WebAPI 通常使用 RESTful 设计风格&#xff0c;然而近年来 GraphQL 作为一种新的 API 查询语言逐渐获得广泛应用。GraphQL 允许客户端精确地查询所需的数据&#xff0c;减少了过度请求和不足请求的问题。本文将详细讨论在项目中用 Grap…

Linux高阶——0928—Github本地仓库与云端仓库关联

1、安装代理软件 steam 选择Github和系统代理模式&#xff0c;一键加速即可 2、 安装Git 3、访问Github网站&#xff0c;创建新用户 4、Github探索 &#xff08;1&#xff09;Explore探索标签 &#xff08;2&#xff09;工程结构 用户名/仓库名 自述文件&#xff0c;用markdo…

SPI通信——FPGA学习笔记14

一、简介 SPI(Serial Periphera Interface&#xff0c;串行外围设备接口)通讯协议&#xff0c;是 Motorola 公司提出的一种同步串行接口技术&#xff0c;是一种高速、全双工、同步通信总线&#xff0c;在芯片中只占用四根管脚用来控制及数据传输&#xff0c;广泛用于 EEPROM、F…

多层感知机(MLP)实现考勤预测二分类任务(sklearn)

1、基础应用&#xff1a; https://blog.csdn.net/qq_36158230/article/details/118670801 多层感知机(MLP)实现考勤预测二分类任务(sklearn) 2、分类器参数&#xff1a;https://scikit-learn.org/dev/modules/generated/sklearn.neural_network.MLPClassifier.html 3、损失函数…

Redis配置篇 - 指定Redis配置的三种方式,以及Redis配置文件介绍

文章目录 1 指定Redis配置的三种方式1.1 通过命令行参数来指定Redis配置1.2 通过配置文件来指定Redis配置1.3 在服务器运行时更​​改 Redis 配置 2 关于Redis配置文件 1 指定Redis配置的三种方式 1.1 通过命令行参数来指定Redis配置 在redis启动时&#xff0c;可以直接通过命…

绿野仙踪不仅是童话,还是便宜又好用的产品测试法!

以 ChatGPT 为代表的大语言模型爆火后&#xff0c;推动了对话类人工智能产品的高速发展&#xff0c;我们已经看到了如智能助理、问答系统、自动写作等多种类型的个性化对话类 AI 服务。 AI 能力的提升让人们对智能 AI 产品的期望越来越高&#xff0c;相关产品的用户体验也因此变…

【音频可视化】通过canvas绘制音频波形图

前言 这两天写项目刚好遇到Ai对话相关的需求&#xff0c;需要录音功能&#xff0c;绘制录制波形图&#xff0c;写了一个函数用canvas实现可视化&#xff0c;保留分享一下&#xff0c;有需要的直接粘贴即可&#xff0c;使用时传入一个1024长的&#xff0c;0-255大小的Uint8Arra…