19 Nginx服务器版本升级需求分析
19 Nginx服务器版本升级需求分析
19.1 需求分析
如果想对 Nginx 的版本进行更新或添加新模块,最简单的做法就是停止当前的 Nginx 服务,然后开启新的 Nginx 服务,但是在这一段时间内会导致用户无法访问服务器,为了解决这个问题,需要用到Nginx 服务器提供的平滑升级功能,这也是Nginx的一大特点,这种方式,可以使 Nginx 在 7*24 小时不间断的提供服务,分析需求:
需求:Nginx 的版本最开始使用的是 Nginx-1.14.2,由于服务升级,需要将 Nginx 的版本升级到 Nginx-1.16.1,要求 Nginx 不能中断提供服务
为了应对上述需求,提供两种解决方案:
方案一:使用 Nginx 服务信号完成 Nginx 的升级
方案二:使用 Nginx 安装目录的 make 命令完成升级
19.2 环境准备
1.先准备两个版本的 Nginx,分别是 1.14.2 和 1.16.1
[root@nginx-120 ~]# ll total 2004 -rw-r--r-- 1 root root 1015384 Mar 12 13:09 nginx-1.14.2.tar.gz -rw-r--r-- 1 root root 1032630 Mar 12 13:09 nginx-1.16.1.tar.gz
2.使用 Nginx 源码安装的方式将 1.14.2 版本安装成功并正确访问
# 解压安装包文件 [root@nginx-120 ~]# tar -xf nginx-1.14.2.tar.gz [root@nginx-120 ~]# tar -xf nginx-1.16.1.tar.gz [root@nginx-120 ~]# ls -lrt total 2004 drwxr-xr-x 8 1001 1001 158 Dec 4 2018 nginx-1.14.2 drwxr-xr-x 8 1001 1001 158 Aug 13 2019 nginx-1.16.1 -rw-r--r-- 1 root root 1015384 Mar 12 13:09 nginx-1.14.2.tar.gz -rw-r--r-- 1 root root 1032630 Mar 12 13:09 nginx-1.16.1.tar.gz [root@nginx-120 ~]# cd nginx-1.14.2/ # 安装依赖 [root@nginx-120 ~/nginx-1.14.2]# yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel .......... # 配置文件 [root@nginx-120 ~/nginx-1.14.2]# ./configure .......... # 编译以及编译安装 [root@nginx-120 ~/nginx-1.14.2]# make && make install .......... [root@nginx-120 ~/nginx-1.14.2]# ll /usr/local/nginx/sbin/nginx -rwxr-xr-x 1 root root 3746800 Mar 23 11:43 /usr/local/nginx/sbin/nginx [root@nginx-120 ~/nginx-1.14.2]# /usr/local/nginx/sbin/nginx -v nginx version: nginx/1.14.2 [root@nginx-120 ~/nginx-1.14.2]# /usr/local/nginx/sbin/nginx [root@nginx-120 ~/nginx-1.14.2]# ps -ef|grep nginx root 10430 1 0 12:01 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx nobody 10431 10430 0 12:01 ? 00:00:00 nginx: worker process root 10433 1453 0 12:01 pts/0 00:00:00 grep --color=auto nginx
浏览器访问:http://10.0.0.120/

3.将 Nginx-1.16.1 进行参数配置和编译,不需要进行安装
[root@nginx-120 ~/nginx-1.14.2]# cd ../nginx-1.16.1/ # 因为在同一台服务器上,所以不需要再安装环境依赖 [root@nginx-120 ~/nginx-1.16.1]# ./configure .......... [root@nginx-120 ~/nginx-1.16.1]# make .......... [root@nginx-120 ~/nginx-1.16.1]# cd objs/ [root@nginx-120 ~/nginx-1.16.1/objs]# ./nginx -v nginx version: nginx/1.16.1
———————————————————————————————————————————————————————————————————————————
无敌小马爱学习
浙公网安备 33010602011771号