LoginSignup
7
5

More than 5 years have passed since last update.

【nginx】バージョンアップ方法

Posted at

nginxのバージョンアップ。
今のバージョンファイルを上書きすることなくシンボリックリンクで向き先を変えるやり方。

現在のバージョンチェック

# /usr/local/nginx/sbin/nginx -v
 nginx version: nginx/1.5.8

ソースダウンロード解凍

# cd /usr/local/src
# wget http://nginx.org/download/nginx-1.9.14.tar.gz  
# tar xvf nginx-1.9.14.tar.gz
# cd nginx-1.9.14

インストール

# ./configure --prefix=/usr/local/nginx-1.9.14 \
  --user=nginx \
  --group=nginx \
  --with-http_ssl_module \
  --with-http_realip_module \
  --with-http_addition_module \
  --with-http_xslt_module \
  --with-http_sub_module \
  --with-http_dav_module \
  --with-http_flv_module \
  --with-http_gzip_static_module \
  --with-http_random_index_module \
  --with-http_secure_link_module \
  --with-http_stub_status_module \
  --add-module=/usr/local/src/headers-more-nginx-module
# make && make install

設定ファイルコピー

# cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx-1.9.14/conf/nginx.conf
# cp /usr/local/nginx/conf/certs.pem /usr/local/nginx-1.9.14/conf/certs.pem
# cp /usr/local/nginx/conf/ssl-oisix.key /usr/local/nginx-1.9.14/conf/ssl-oisix.key
# cp -r /usr/local/nginx/conf/virtualhost /usr/local/nginx-1.9.14/conf/
# chown -R nginx. /usr/local/nginx-1.9.14

シンボリックリンクで切り替え

# ln -nfs /usr/local/nginx-1.9.14 /usr/local/nginx

設定ファイルのシンタックスチェック

# /usr/local/nginx/sbin/nginx -t
 syntax is okを確認

リクエストを落とさずにプロセスを切り替える

# ps aux |grep nginx
masterのプロセスIDを確認
# kill -USR2 5559
# kill -WINCH  5559
# kill -QUIT  5559
# /usr/local/nginx/sbin/nginx -s reload
7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5