yumに優先順位をつけよう
先に結論を書いてしまうと「yum-plugin-priorities」というツールを導入します。 参考:yum リポジトリの追加・優先順位を設定 〜 CentOS6
何で優先順位をつける必要があるかと言うと、php7を導入した場合baseのリポジトリではphp5を優先しようとするのでphp7の更新の度に[remi-php70.repo]を有効にしてあげる必要があります。
糞めんどい(´・ω・`)
これだと毎回大変なので「yum update」で済ませたいのです。
そこで活躍するのが、「yum-plugin-priorities」です(`・ω・´)
使い方
上記のツールを導入すると、リポジトリに優先順位をつけることができるようになります。 まずはツールを導入します。
yum -y install yum-plugin-priorities
次にリポジトリに優先順位をつけます。 僕の場合はですが、下記の様にしています。(リポジトリの該当する箇所のみ記載)
# This repository only provides PHP 7.0 and its extensions # NOTICE: common dependencies are in "remi-safe" [remi-php70] name=Remi's PHP 7.0 RPM repository for Enterprise Linux 6 - $basearch #baseurl=http://rpms.remirepo.net/enterprise/6/php70/$basearch/ mirrorlist=http://rpms.remirepo.net/enterprise/6/php70/mirror enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi priority=1 [remi-php70-debuginfo] name=Remi's PHP 7.0 RPM repository for Enterprise Linux 6 - $basearch - debu ginfo baseurl=http://rpms.remirepo.net/enterprise/6/debug-php70/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi priority=1
# Repository: http://rpms.remirepo.net/ # Blog: http://blog.remirepo.net/ # Forum: http://forum.remirepo.net/ [remi] name=Remi's RPM repository for Enterprise Linux 6 - $basearch #baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/ mirrorlist=http://rpms.remirepo.net/enterprise/6/remi/mirror enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi priority=1
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 priority=2 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 priority=2 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 priority=2 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 priority=2 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 priority=2
更にbaseの方にPHP関係ではこのリポジトリは使用しない 「exclude=php*」をつけた方が良いのかもしれませんが、今のところはつけていません。
注意
今回の記事は僕の場合の話です。 「yum update」をする場合は「-y」オプションをつけないで何がアップデートされるか1度は必ず確認してから行ってください。