天天看點

linux平滑更新nginx,Linux----------nginx平滑更新

1、nginx添加新子產品

1.檢視已編譯參數并複制參數(user開始)

nginx -V

*** --usr=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module

2.下載下傳新的echo 子產品,并放入指定位置

wget https://github.com/chendao2015/echo-nginx-module下載下傳

wget https://github.com/openresty/echo-nginx-module/archive/v0.61.tar.gz

mv echo-nginx-module-master /usr/local/src/nginx-1.8.1/echo-nginx-module

3.從新編譯參數

./configure --複制參數 --add-module=/usr/local/src/nginx-1.8.1/echo-nginx-module

make

##這裡隻須要make,必定不要make install,否則會覆寫原有檔案

4.備份原二進制檔案,而後用新生成的二進制檔案替換nginx二進制檔案

cp /usr/local/nginx/sbin/nginx{,.old}

\cp /usr/loca/nginx-1.8.1/objs/nginx /usr/local/nginx/sbin/nginx

5.從新啟動nginx

nginx -t

nginx -s reload

2、更新nginx

1.備份原有nginx二進制檔案

cp /usr/local/nginx/sbin/nginx{,.old}

2.檢視nginx編譯參數并複制參數

nginx -V

****  --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6

3.編譯安裝新版本nginx,安裝路徑需與舊版一緻

./configure --prefix/usr/local/nginx-1.15 --複制參數

make

##這裡隻須要make,必定不要make install,否則會覆寫原有檔案

4.準備新版本nginx配置檔案

cp /usr/local/nginx/conf/nginx.conf  /usr/local/nginx-1.15/conf/nginx.conf

5.殺死原有nginx程序,啟動新版本的nginx

pkill nginx

/usr/local/nginx-1.15/sbin/nginx