1、開始之前首先查看當(dāng)前的使用版本以及編譯時(shí)的參數(shù):
1
2
3
4
5
6
|
[root@www ~] # /usr/local/nginx/sbin/nginx -V nginx version: nginx /1 .12.2 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --user=www --group=www --prefix= /usr/local/nginx --with-http_stub_status_module --with-http_ssl_module |
將編譯參數(shù)復(fù)制出來(lái),編譯新版本的時(shí)候會(huì)用到。
2、下載新版本:http://nginx.org/en/download.html
1
2
3
4
5
|
cd nginx-1.14.0 . /configure --user=www --group=www --prefix= /usr/local/nginx --with-http_stub_status_module --with-http_ssl_module make |
3、執(zhí)行完成之后,不需要make install ,備份原來(lái)的二進(jìn)制啟動(dòng)文件,然后將新版的啟動(dòng)文件拷貝過去
1
2
|
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx .bak [root@www nginx-1.14.0] # cp objs/nginx /usr/local/nginx/sbin/nginx |
4、測(cè)試一下復(fù)制過來(lái)的文件是否生效:
1
2
3
|
[root@www nginx-1.14.0] # /usr/local/nginx/sbin/nginx -t 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 |
5、發(fā)送USR2信號(hào)給nginx master 進(jìn)程(nginx服務(wù)接收到USR2信號(hào)后,首先會(huì)將舊的nginx.pid文件添加后綴.oldbin,變?yōu)閚ginx.pid.oldbin,然后執(zhí)行新版本的二進(jìn)制文件啟動(dòng)服務(wù),如果新的服務(wù)啟動(dòng)成功,系統(tǒng)中將有新舊兩個(gè)Nginx服務(wù)共同提供web服務(wù))
1
2
3
4
5
6
7
8
|
kill -USR2 ` cat /usr/local/nginx/logs/nginx .pid` [root@www nginx-1.14.0] # ps -ef | grep nginx root 22644 1 0 23:30 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx www 22648 22644 0 23:30 ? 00:00:00 nginx: worker process root 25784 22644 0 23:47 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx www 25789 25784 0 23:47 ? 00:00:00 nginx: worker process |
6、通過發(fā)送WINCH信號(hào)(平緩?fù)V箇orker process)和QUIT信號(hào)(平緩?fù)V筃ginx服務(wù))停止舊的Nginx服務(wù)進(jìn)程
1
2
|
kill -WINCH `cat /usr/local/nginx/logs/nginx.pid.oldbin` kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin` |
7、升級(jí)完成,最后看一下nginx版本:
1
2
|
/usr/local/nginx/sbin/nginx -v nginx version: nginx/1.14.0 |
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。
原文鏈接:http://www.cnblogs.com/Template/p/9348623.html