CentOS 6 で nginx を 1.6.3 から 1.8.x にアップグレードする方法

CentOS 6 で nginx を 1.6.3 から 1.8.x にアップグレードする方法

CentOS 6、nginx 1.6.3を使用しています

$nginx -v
nginx version: nginx/1.6.3

そして、nginxを1.8にアップグレードしたいのですが、add_header [always] ディレクティブ必要である

私はフォローしていたnginx18 パッケージアップグレードを実行しようとしましたが、次のエラーが発生しました

$yum list nginx*
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirrors.service.networklayer.com
 * epel: free.nchc.org.tw
 * extras: mirrors.service.networklayer.com
 * updates: mirrors.service.networklayer.com
 * webtatic: uk.repo.webtatic.com
Installed Packages
nginx16.x86_64       1.6.3-1.w6       @webtatic
Available Packages
nginx18.x86_64       1.8.0-1.w6       webtatic

走るとyum install -y nginx18

Transaction Check Error:
  file /usr/sbin/nginx from install of nginx18-1.8.0-1.w6.x86_64 conflicts with file from package nginx16-1.6.3-1.w6.x86_64
  file /usr/lib64/perl5/vendor_perl/auto/nginx/nginx.so from install of nginx18-1.8.0-1.w6.x86_64 conflicts with file from package nginx16-1.6.3-1.w6.x86_64
  file /usr/lib64/perl5/vendor_perl/nginx.pm from install of nginx18-1.8.0-1.w6.x86_64 conflicts with file from package nginx16-1.6.3-1.w6.x86_64
  file /usr/share/man/man3/nginx.3pm.gz from install of nginx18-1.8.0-1.w6.x86_64 conflicts with file from package nginx16-1.6.3-1.w6.x86_64

Error Summary

CentOS 6 で nginx を 1.6.3 から 1.8 にアップグレードする正しい手順を教えていただけませんか? 理想的には、yum removeサーバーのダウンタイムの原因となる nginx16 を指定してから nginx18 をインストールするのは避けてください。

答え1

nginx パッケージは複数のバージョンを同時にインストールするように設計されていないため、古いバージョンをアンインストールして新しいバージョンをインストールする必要があります。

$ yum remove nginx16
$ yum install nginx18

あるいは、

 $ yum install yum-plugin-replace
 $ yum replace nginx16 --replace-with=nginx18
 $ service nginx restart

ただし、まずはテストサーバーでテストしたほうがよいでしょう。

関連情報