nginx平滑(不重啓)升級

1.升級和安裝nginx第三方模塊同樣,須要查看原來安裝nginx的版本以及編譯的參數

[root@ittestserver1 opt]# /usr/local/nginx2/sbin/nginx -V
nginx version: nginx/1.10.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) 
built with OpenSSL 1.1.0e  16 Feb 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx2 --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_stub_status_module --with-http_v2_module --with-openssl=/tmp/install/openssl-1.1.0e --with-http_v2_module



#注意【configure arguments】,升級的時候,要保持一致!

2.下載要升級的nginx版本

這個再也不贅述,本身用wget或者去官網上面下壓縮包,而後ftp上傳便可。下載地址:http://nginx.org/cn/download.htmlhtml

3.解壓ningx安裝包,進行configure 操做(參數與步驟1中查詢出來額一致)。

[root@ittestserver1 soft]# tar xf nginx-1.12.1.tar.gz 
[root@ittestserver1 soft]# cd nginx-1.12.1
[root@ittestserver1 nginx-1.12.1]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[root@ittestserver1 nginx-1.12.1]# ./configure  --prefix=/usr/local/nginx2 \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_stub_status_module \
--with-http_v2_module \
--with-openssl=/tmp/install/openssl-1.1.0e \
--with-http_v2_module

PS:服務器若是沒有安裝nginx依賴的軟件,好比openssl、prce等,且本身不是root用戶,沒法使用yum進行安裝,能夠使用參數來指定相應依賴的源碼路徑(依賴源碼需本身去下載),例如指定prce依賴:--with-pcre=【prce源碼】nginx

4.執行make,切記不是make install

[root@ittestserver1 soft]# make

5.備份原來老的nginx文件,並將新的nginx文件複製過去

[root@ittestserver1 nginx-1.12.1]# mv /usr/local/nginx2/sbin/nginx /usr/local/nginx2/sbin/nginx.bak

[root@ittestserver1 nginx-1.12.1]# cp objs/nginx  /usr/local/nginx2/sbin/

6.使用make upgrade替換老的nginx進程(平滑升級)

[root@ittestserver1 nginx-1.12.1]# make upgrade


#注意是在進行make的目錄下進行的

7.執行/usr/local/nginx2/sbin/nginx -V查看nginx最新的版本及編譯的參數

[root@ittestserver1 nginx-1.12.1]# /usr/local/nginx2/sbin/nginx -V
nginx version: nginx/1.12.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) 
built with OpenSSL 1.1.0e  16 Feb 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx2 --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_stub_status_module --with-http_v2_module --with-openssl=/tmp/install/openssl-1.1.0e --with-http_v2_module

 

參考:https://blog.51cto.com/liqingbiao/1948430服務器

相關文章
相關標籤/搜索