CentOS下平滑無縫升級Nginx到最新版本

來源:互聯網
上載者:User

CentOS下平滑無縫升級Nginx到最新版本

1、如同安裝nginx第三方模組一樣,需要查看原來安裝的nginx的版本以及編譯的參數

[root@localhost ~]# /usr/local/nginx/sbin/nginx -Vnginx version: nginx/1.7.8built by gcc 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) TLS SNI support enabledconfigure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --add-module=/root/ngx_cache_purge-2.2

2、下載想要升級nginx的版本

wget -c http://nginx.org/download/nginx-1.7.9.tar.gz

3、解壓進入目錄開始運行上面所查詢到的編譯參數

tar zxvf nginx-1.7.9.tar.gzcd /root/nginx-1.7.9./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --add-module=/root/ngx_cache_purge-2.2

4、然後make,但不要make install,切記!

可能會有錯誤提示:

cc1: all warnings being treated as errors
make[1]: *** [objs/addon/ngx_cache_purge-2.2/ngx_cache_purge_module.o] 錯誤 1
make[1]: 離開目錄“/root/nginx-1.7.9”
make: *** [build] 錯誤 2

出現這種錯誤提示的原因,是我的這個nginx是最新的,而ngx_cache_purge模組版本是舊的。建議使用最新的版本。如果沒有第三方模組,一般情況下,直接升級nginx是不會報錯誤提示的。

下載解壓後,修改編譯參數中的:–add-module=/root/ngx_cache_purge-2.3

wget -c http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gztar zxvf ngx_cache_purge-2.3.tar.gz

重新運行這些參數順利通過後,make

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --add-module=/root/ngx_cache_purge-2.3

5、make編譯完,在objs目錄下有一個nginx執行檔案

6、備份下原來老的nginx檔案

mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

7、在把新objs下的nginx cp到sbin下

cp objs/nginx /usr/local/nginx/sbin/nginx

8、執行 /usr/local/nginx/sbin/nginx -t 測試下,顯示沒有問題。

9、使用make upgrade 替換老的nginx進程

10、再次執行:/usr/local/nginx/sbin/nginx -V將會顯示新的nginx的版本及編譯的參數。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.