nginx upgrade

覆蓋式升級:html

http://leftshift.io/upgrading-nginx-to-the-latest-version-on-ubuntu-serversnginx


升級目的:nginx1.3版本以後支持了websocket ,簡單的配個代理就能讓你的websocket工做正常web

本次針對已有nginx非覆蓋式升級,具體以下shell

    1. 下載nginxubuntu

    2. 解壓編譯websocket

    3. 備份拷貝原有配置文件socket

    4. 關閉原有服務,啓動新服務spa

若是有weget
$ weget http://nginx.org/download/nginx-1.8.0.tar.gz

或者訪問 http://nginx.org/en/download.html

推薦1.8.0 穩定版

$ tar -zxvf nginx-1.8.0.tar.gz
$ cd nginx-1.8.0
$ ./configure --prefix=/usr/local/nginx-1.8.0

Mac OX 下也許你能順利經過,可是若是Ubuntu下可能會報PCRE依賴包沒有 so 你能夠以下操做:

$ apt-get install libpcre3 libpcre3-dev

成功後可執行安裝了
$ make && make install


這樣在你的/usr/local/nginx-1.8.0下就成功安裝了一個nginx 和原有的不衝突

$ cd /usr/local/nginx-1.8.0
$ ls -lrt
drwxr-xr-x  2 root     root 4096 Aug 17 10:32 sbin
drwxr-xr-x  2 root     root 4096 Aug 17 10:32 html
drwxr-xr-x  2 root     root 4096 Aug 17 10:35 logs
drwx------  2 www-data root 4096 Aug 17 10:35 uwsgi_temp
drwx------  2 www-data root 4096 Aug 17 10:35 scgi_temp
drwx------  2 www-data root 4096 Aug 17 10:35 fastcgi_temp
drwxr-xr-x  5 root     root 4096 Aug 17 19:49 conf
drwx------ 12 www-data root 4096 Aug 17 22:37 proxy_temp
drwx------  2 www-data root 4096 Aug 17 22:46 client_body_temp

ldd nginx 能夠看到並無本身的.so 依賴文件

ldd /usr/local/nginx-1.8.0/sbin/nginx  (ubuntu)
otool -L ~/dwetl/nginx1.8.0/sbin/nginx (Mac OX)

接着關閉&備份已有nginx 配置文件等

echo 'stop nginx ....'
service nginx stop

echo 'cp config file.'
cp /etc/nginx/nginx.conf /usr/local/nginx-1.8.0/conf/
cp -r /etc/nginx/conf.d/ /usr/local/nginx-1.8.0/conf/

echo 'upgrade  nginx.'
mv /usr/sbin/nginx /usr/sbin/nginx1.1.19    # 保留以前的nginx 萬一出問題了咋辦呢,留條後路
ln -s /usr/local/nginx-1.8.0/sbin/nginx /usr/sbin/nginx

echo 'restart  nginx.'
service nginx restart

輕鬆搞定
相關文章
相關標籤/搜索