高端营销型网站建设,不干胶印刷网站建设,云数据库可以做网站吗,济南pc网站建设公司背景介绍
因为一些原因#xff0c;比如说 Nginx 发现漏洞、应用一些新的模块等等#xff0c;想对 Nginx 的版本进行更新#xff0c;最简单的做法就是停止当前的 Nginx 服务#xff0c;然后开启新的 Nginx 服务。但是这样会导致在一段时间内#xff0c;用户是无法访问服务…背景介绍
因为一些原因比如说 Nginx 发现漏洞、应用一些新的模块等等想对 Nginx 的版本进行更新最简单的做法就是停止当前的 Nginx 服务然后开启新的 Nginx 服务。但是这样会导致在一段时间内用户是无法访问服务器因此需要进行平滑升级。
源码下载
nginx 官网找到最新稳定版本。原先的版本为 nginx-1.18.0
http://nginx.org/en/download.html# 安装编译后的路径 /usr/local/soft/nginx
mkdir -p /usr/local/soft cd /usr/local/soft
wget http://nginx.org/download/nginx-1.22.1.tar.gz解压源码
tar -xzvf nginx-1.22.1.tar.gz旧版参数
查看当前版本启动参数以便用于新版启动。
# 查看启动参数
/usr/local/soft/nginx/sbin/nginx -V如上图得知原先 nginx 的启动命令为
--prefix/usr/local/soft/nginx --with-http_stub_status_module --with-http_ssl_module --add-module/usr/local/soft/nginx/modules/nginx-upstream-fair-master --add-module/usr/local/soft/nginx/modules/ngx_cache_purge-2.3编译新版
确认是在新版源码目录下执行如果不是则需要进入新版本源码目录。
cd /usr/local/soft/nginx-1.22.1
# 对新版本 nginx 进行配置
./configure --prefix/usr/local/soft/nginx --with-http_stub_status_module --with-http_ssl_module --add-module/usr/local/soft/nginx/modules/nginx-upstream-fair-master --add-module/usr/local/soft/nginx/modules/ngx_cache_purge-2.3接着进行 make注意不是 make install否则后果很严重。
make这样最新版本 nginx 的目录下会多出来一个 objs 目录如下图所示 备份旧版
备份当前版本的 nginx。
mv /usr/local/soft/nginx/sbin/nginx /usr/local/soft/nginx/sbin/nginx.old拷贝新版
将编译好的 objs 目录下的 nginx 文件复制到 /usr/local/soft/nginx/sbin 目录。 cp /usr/local/soft/nginx-1.22.1/objs/nginx /usr/local/soft/nginx/sbin/nginx命令升级
make upgrade 命令升级。
cd /usr/local/soft/nginx-1.22.1 make upgrade检查验证
可看到版本已变为 1.22.1并且过程中服务不中断。 /usr/local/soft/nginx/sbin/nginx -v