1. 程式人生 > >nginx不間斷服務平滑升級

nginx不間斷服務平滑升級

是否 con 升級 efi 切換 fig stat 備份 sbin

(1)備份舊的nginx和配置文件

cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/bak_nginx                #備份舊版程序
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/bak_nginx.conf            #備份配置文件

(2)編譯安裝新版本       

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module;make;make install   

(3)檢查新版是否正常

/usr/local/nginx/sbin/nginx -V          #檢查版本信息是否正確   
/usr/local/nginx/sbin/nginx -t            #測試新版本Nginx配置是否正常,如看到xxxxxx test is successful的提示,說明配置正常

(4)切換舊版工作進程

kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`       #平滑升級可執行的程序
    
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`  #正常停止舊版本進程

nginx不間斷服務平滑升級