nginx make upgrade 平滑升級


[root@localhost ~]# /usr/local/nginx/sbin/nginx -V nginx version: nginx/1.15.9 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_addition_module --with-http_flv_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-http_v2_module --add-module=/root/ngx_http_substitutions_filter_module 
  • 下載最新的nginx,(官方下載地址:http://nginx.org/en/download.html)
[root@localhost ~]# wget -c http://nginx.org/download/nginx-1.17.0.tar.gz --2019-06-19 12:37:46-- http://nginx.org/download/nginx-1.17.0.tar.gz Resolving nginx.org (nginx.org)... 95.211.80.227, 62.210.92.35, 2001:1af8:4060:a004:21::e3 Connecting to nginx.org (nginx.org)|95.211.80.227|:80... connected. HTTP request sent, awaiting response... 206 Partial Content Length: 1032978 (1009K), 1016293 (992K) remaining [application/octet-stream] Saving to: nginx-1.17.0.tar.gz 100%[++=======================================================================================================================================>] 1,032,978 33.9KB/s in 33s 2019-06-19 12:38:19 (30.3 KB/s) - nginx-1.17.0.tar.gz saved [1032978/1032978] [root@localhost ~]# 
  • 解壓nginx-1.17.0.tar.gz,並cd到解壓目錄
[root@localhost ~]# tar -zxvf nginx-1.17.0.tar.gz ……………………………………………………………… nginx-1.17.0/auto/cc/name nginx-1.17.0/auto/cc/owc nginx-1.17.0/auto/cc/sunc [root@localhost ~]# cd nginx-1.17.0 [root@localhost nginx-1.17.0]# 
  • 配置安裝選項,要和我們上面查詢版本時所查看到的配置保持一致,要不你可就少安裝功能了,導致一些功能不可用了。
[root@localhost nginx-1.17.0]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_addition_module --with-http_flv_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-http_v2_module --add-module=/root/ngx_http_substitutions_filter_module checking for OS + Linux 3.10.0-957.1.3.el7.x86_64 x86_64 checking for C compiler ... found + using GNU C compiler + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ……………………………………………………………………………………………………………………………………………… ………………………………………………………………………………………………………………………………………………
./configure –help 查看詳細的說明幫助 生成makefile文件
  • 編譯
[root@localhost nginx-1.17.0]# make …………………………………………………………………………………… …………………………………………………………………………………… sed -e "s|%%PREFIX%%|/usr/local/nginx|" \ -e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \ -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \ -e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \ < man/nginx.8 > objs/nginx.8 make[1]: Leaving directory `/root/nginx-1.17.0'
將高級語言生成二進制語言
  • 運行平滑升級命令
[root@localhost nginx-1.17.0]# make upgrade /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 kill -USR2 `cat /usr/local/nginx/logs/nginx.pid` sleep 1 test -f /usr/local/nginx/logs/nginx.pid.oldbin kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin` [root@localhost nginx-1.17.0]# 

注:到這里運行平滑級后,升級並沒有完成,需要再次編譯安裝才可以,原本第一次認為到這里升級就結束了,但查詢版本號還是原來的版本。

  • 編譯安裝
[root@localhost nginx-1.17.0]# make install
安裝到想應目錄
第二種方法
#先將之前的nginx先備份
mv /usr/local/nginx/sbin/nginx /usr/local/nginx.bak
#將make好的nginx拷貝到原來nginx安裝目錄/usr/local/nginx/sbin
 cp -rp objs/nginx /usr/local/nginx/sbin/
#平滑啟動
make upgrade

 

至此我們的平滑升級結束,我們可以再次查詢nginx的版本號。

 

  • nginx版本查詢
[root@localhost nginx-1.17.0]# /usr/local/nginx/sbin/nginx -V
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM