nginx平滑升級,nginx

來源:互聯網
上載者:User

nginx平滑升級,nginx

原文發表於:2010-12-09
轉載至cu於:2012-07-21

閑來無事把nginx伺服器升級了,因為沒有經常玩linux,記錄下來以免將來再升級的時候又去查資料。

下載:

[root@liuawblizfpws~]#wget http://nginx.org/download/nginx-0.*.*.tar.gz (版本號碼已修改)

解壓:

[root@liuawblizfpws ~]#tar zxvf  nginx-0.*.*.tar.gz (版本號碼已修改)

這裡順便把nginx的版本號碼修改了,起到一定的安全作用。

修改源碼檔案:

[root@liuawblizfpws ~]#vim nginx-0.*.*/src/core/nginx.h#define NGINX_VERSION      "*.$.&"   (版本號碼)#define NGINX_VER          "net/" NGINX_VERSION  (伺服器名字)
重新編譯之前需要查看之前的nginx的安裝資訊:
[root@liuawblizfpws ~]#/usr/local/nginx/sbin/nginx -V
得到資訊(路徑因人而異):
nginx: configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
編譯,但不安裝;在編譯目錄下的objs目錄下的nginx檔案即是新的執行檔案:
[root@liuawblizfpws nginx-0.*.*]#./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module[root@liuawblizfpws nginx-0.*.*]#make
備份原有nginx檔案:
[root@liuawblizfpws ~]#mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
將已經編譯好的nginx檔案複製到相應的執行路徑下:
cp ~/nginx-0.*.*/objs/nginx /usr/local/nginx/sbin/nginx
測試,以免不能平滑升級:
[root@liuawblizfpws ~]#/usr/local/nginx/sbin/nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
測試通過則將nginx.pid修改為您nginx.pid.oldbin,同時啟動新的nginx:
[root@liuawblizfpws ~]#kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
退出原nginx:
[root@liuawblizfpws ~]#kill -QUIT `cat /usr/loca/nginx/logs/nginx.pid.oldbin`
查驗:
[root@liuawblizfpws ~]#curl -I netonline.meHTTP/1.1 200 OKServer: net/*.$.&Date: Thu, 09 Dec 2010 05:13:36 GMT

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.