Smooth upgrade of Nginx

WBOY
Release: 2016-07-29 09:04:31
Original
1020 people have browsed it

Sometimes, we need to upgrade our server to a higher version. At this time, if we forcibly stop the server and then upgrade directly, the processes originally running on the server will be affected. How to solve this problem? This can be solved through smooth upgrade. During a smooth upgrade, running processes will not be stopped. These processes will continue to process requests, but will no longer accept new requests. These old processes will stop after processing the requests that are still being processed. During this smooth upgrade, the newly opened process will handle new requests.

1. Check the current version

<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>
Copy after login

2. Upgrade to the new version

<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>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the smooth upgrade of Nginx, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!