0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WEBサーバをバージョンアップしました

Last updated at Posted at 2020-01-31

初めに

昨今、ウェブ界隈で話題になっている「nginx」というものがあります。これはwebサーバ業界に最近登場したオープンソースソフトウェア(OSS)で、本来はプロキシサーバとして開発されたものが通信早いから一般のwebサーバに使える!ということでwebサーバになったものらしく、静的コンテンツの表示速度の速さからもサービス提供者間で人気が急上昇中のものです。

そしてそんなサーバを使い始めて早2年、そろそろバージョンをアップしたほうがいいだろうということでnginxのバージョンをアップすることにしました。

環境

導入した環境は以下の通りです

  • サーバ : さくらのVPS
  • OS : CentOS 7

導入

では、導入をしていきます。とりあえず、元々利用していたnginxの過去のバージョンをアンインストールします。以下は行ったコマンド操作です。

とりあえず、nginxに関するファイルがどこにあるのかを調べておきます。

$ whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx

次に、上記ファイルのうち、設定用のファイル(.conf)はバックアップを取っておきましょう。

$ cp -r /etc/nginx/ ./

そして、必要なnginxのインストール用の圧縮ファイルを公式サイトから引っ張ってきて、設定用のファイルを設置します。

$ wget http://nginx.org/download/nginx-X.XX.X.tar.gz
$ tar xfvz nginx-X.XX.X.tar.gz
$ cd ./nginx-X.XX.X
$ ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

上の最後のコマンドを実行して、出力メッセージに

Configuration summary
  + using threads
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library
...

と出てくれば成功です。
そして、makeコマンドを実行すれば設定は完了です。

$ make
$ make install

そして、先ほどバックアップを取った設定ファイルを引越しします。

$ pwd
(wgetした階層)/nginx-X.XX.X
$ rm -rf /etc/nginx
$ mv ../nginx/ /etc/

あとは更新されたかをバージョン確認。

$ nginx -V
nginx version: nginx/X.XX.X ← ここでインストールしたいバージョンだったらOK!
built by gcc X.X.X 20XXXXXX (Red Hat 4.8.5-28) (GCC)
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

最後に

これはあくまで筆者が行った更新方法なので、もしかしたら世間にはもっと良い方法があるかもしれません。なので、もっと良いと思われる方法があったら皆さんぜひご教授ください。

あと、nginxの発表によると、新しい通信プロトコル「QUIC」を用いたwebサーバを開発しているということなので、公開され次第導入したいと思います。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?