有时,我们需要对我们的服务器进行升级更高版本。此时,如果我们强行将服务器停止然后直接升级,这样原来在服务器上运行着的进程就会被影响。如何解决这个问题呢?可以通过平滑升级的方式来解决。平滑升级时,不会停掉在运行着的进程,这些进程会继续处理请求,但不会再接受新请求,在这些老进程在处理完还在处理的请求后,停止。此平滑升级的过程中,新开的进程会处理新请求。
1、查看当前版本
<code>[root<span>@Admin</span><span>/]# cd /opt/nginx/sbin/</span> [root<span>@Admin</span> sbin]<span># ./nginx -V</span> nginx <span>version</span>: nginx/<span>1.8</span><span>.0</span> built <span>by</span> gcc <span>4.8</span><span>.5</span><span>20150623</span> (Red Hat <span>4.8</span><span>.5</span>-<span>4</span>) (GCC) configure <span>arguments</span>: --prefix=<span>/opt/nginx/</span></code>
2、升级到新的版本
<code>下载新版安装包到/tmp目录下 [root<span>@Admin</span> tmp]<span># ls</span> nginx-<span>1.8</span><span>.0</span>.tar.gz nginx-<span>1.9</span><span>.10</span>.tar.gz 解压到当前目录 [root<span>@Admin</span> tmp]<span># tar -zxvf nginx-1.9.10.tar.gz </span>进入解压目录进行以下操作 [root<span>@Admin</span> tmp]<span># cd nginx-1.9.10</span> [root<span>@Admin</span> nginx-<span>1.9</span><span>.10</span>]<span># ./configure </span> [root<span>@Admin</span> nginx-<span>1.9</span><span>.10</span>]<span># make</span>进入已安装的nginx目录下,备份当前使用的nginx [root<span>@Admin</span> nginx-<span>1.9</span><span>.10</span>]<span># cd /opt/nginx/sbin/</span> [root<span>@Admin</span> sbin]<span># cp nginx nginx.old</span> [root<span>@Admin</span> sbin]<span># ls</span> nginx nginx.old 将新版本的编译文件复制到安装目录 [root<span>@Admin</span> sbin]<span># cd /tmp/nginx-1.9.10</span> [root<span>@Admin</span> nginx-<span>1.9</span><span>.10</span>]<span># ls</span> auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src [root<span>@Admin</span> nginx-<span>1.9</span><span>.10</span>]<span># cp -rfp objs/nginx /opt/nginx/sbin/</span> cp:是否覆盖<span>"/opt/nginx/sbin/nginx"</span>? y 查看是否升级成功 [root<span>@Admin</span> nginx-<span>1.9</span><span>.10</span>]<span># cd /opt/nginx/sbin/</span> [root<span>@Admin</span> sbin]<span># ./nginx -V</span> nginx <span>version</span>: nginx/<span>1.9</span><span>.10</span> built <span>by</span> gcc <span>4.8</span><span>.5</span><span>20150623</span> (Red Hat <span>4.8</span><span>.5</span>-<span>4</span>) (GCC) configure <span>arguments</span>: </code>
以上就介绍了Nginx的平滑升级,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。