LoginSignup
122
146

More than 5 years have passed since last update.

Yum で任意のバージョンの PHP をインストールする

Last updated at Posted at 2016-07-06

概要

yum の外部リポジトリを利用して任意のバージョンの PHP をインストールする方法をまとめた。2016年7月5日調査。

特別な事情がない限り Remi's Repositoryremi-php54 remi-php55 remi-php56 remi-php70 の各リポジトリを利用するのがよいだろう。

PHP 7.1 を試したい場合は remi リポジトリの php71 パッケージをインストールする。

個人のメンテナンスに依存している野良リポジトリだと問題になる場合は、ベンダーが管理している SCL リポジトリを利用するとよいだろう。(メンテナ同じ人だけど)

remiのphpでつらいところは古いパッケージが残されてないので、あとからパッケージ追加しようとすると必ずphpのバージョンアップになるところ。 1

Remi リポジトリは各マイナーバージョンの最新版しか残っていないため、リリースバージョン(ポイントバージョン)を変えたくない、あるいはリリースバージョン単位で指定したい場合は、アーカイブの残っている IUS や Atomic のリポジトリを使うとよい。

対応表

Remi リポジトリ

PHP リポジトリ パッケージ名 ビルド日 バージョン
7.0.9 remi-php70 php 2016-07-20 7.0.9-1.el7.remi
5.6.23 remi-php56 php 2016-06-22 5.6.23-1.el7.remi
5.5.37 remi-php55 php 2016-06-21 5.5.37-1.el7.remi
5.4.45 remi php 2016-06-23 5.4.45-10.el7.remi
yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum install yum-utils
yum-config-manager --enable remi-php70
yum install php

インストールしたい PHP のバージョンのリポジトリを有効にすればよい。remi を指定すると PHP 5.4.45 がインストールされる。
RHEL/CentOS 6.x の場合は remi-release-6.rpm を参照する。

remi-php71 もあるが、現時点では PHP 5.4.45 がインストールされる模様。

ベンダーリポジトリ (同時インストール可)

PHP リポジトリ パッケージ名 ビルド日 バージョン
5.6.5 centos-sclo-rh rh-php56 2016-03-23 2.0-6.el6
5.5.21 centos-sclo-rh php55 2015-10-05 2.0-1.el6
5.4.40 centos-sclo-rh php54 2015-10-05 2.0-1.el6
5.4.16 updates/7/x86_64 php 2016-05-12 5.4.16-36.1.el7_2.1
5.3.3 base/6/x86_64 php 2016-05-10 5.3.3-47.el6

標準リポジトリ

yum install php

リポジトリの追加なしでインストールすると、RHEL/CentOS 7.x では updates リポジトリの PHP 5.4.16 が、RHEL/CentOS 6.x では base リポジトリの PHP 5.3.3 がインストールされる。
リリースバージョンが古いままだが、ベンダー側でバックポートされているため、原則的には脆弱性の対応は行われている。

The Software Collections (SCL) リポジトリ

yum install centos-release-scl scl-utils
yum install rh-php56
source scl_source enable rh-php56
echo "source scl_source enable rh-php56" >> ~/.bashrc

Software Collection としてインストールされるため、そのまま使用することは出来ない。
RHEL/CentOS 6.x の場合は centos-release-scl の代わりに centos-release-SCL を指定する必要がある。
PHP 5.6 は rh-php56 、PHP 5.4 / 5.5 は php54 php55 と異なるパッケージ名を指定する必要があるので注意。
設定ファイルは 5.4 / 5.5 は /opt/rh/php54/root/etc/php.ini に、5.6 は /etc/opt/rh/rh-php56/php.ini に配置される。

Remi リポジトリ (別バイナリ名/同時インストール可)

PHP リポジトリ パッケージ名 ビルド日 バージョン
7.1.0a2 remi php71 2016-06-22 1.0-0.1.el7.remi
7.0.8 remi php70 2016-06-22 1.0-5.el7.remi
5.6.23 remi php56 2016-06-22 2.1-5.el7.remi
5.5.37 remi php55 2016-06-21 2.1-5.el7.remi
5.4.45 remi php54 2016-06-23 2.1-4.el7.remi
yum install http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum install yum-utils
yum-config-manager --enable remi
yum install php54 php55 php56 php70 php71

各バージョンを同時インストール可能。
バイナリファイルは /usr/bin/php54 などに、設定ファイルは /opt/remi/php54/root/etc/php.ini などに配置される。

source /opt/remi/php71/enable
echo "source /opt/remi/php71/enable" >> ~/.bashrc

詳しくは「Yum で複数バージョンの PHP を共存させる」を参照のこと。

IUS リポジトリ

PHP リポジトリ パッケージ名 ビルド日 バージョン
7.0.9 ius mod_php70u 7.0.9-1.ius.centos7
5.6.24 ius php56u 5.6.24-1.ius.centos7
5.5.38 ius php55u 5.5.38-1.ius.centos7
curl -s https://setup.ius.io/|sh
yum install php70u php70u-cli
curl -s https://setup.ius.io/|sh
yum install php56u

Archives

PHP リポジトリ パッケージ名 ビルド日 バージョン
7.0.8 ius-archive mod_php70u-7.0.8 mod_php70u-7.0.8-1.ius.centos7
7.0.7 ius-archive mod_php70u-7.0.7 mod_php70u-7.0.7-2.ius.centos7
7.0.6 ius-archive mod_php70u-7.0.6 mod_php70u-7.0.6-1.ius.centos7
7.0.5 ius-archive mod_php70u-7.0.5 mod_php70u-7.0.5-1.ius.centos7
7.0.4 ius-archive mod_php70u-7.0.4 mod_php70u-7.0.4-1.ius.centos7
7.0.3 ius-archive mod_php70u-7.0.3 mod_php70u-7.0.3-1.ius.centos7
7.0.2 ius-archive mod_php70u-7.0.2 mod_php70u-7.0.2-1.ius.centos7
7.0.1 ius-archive mod_php70u-7.0.1 mod_php70u-7.0.1-1.ius.centos7
5.6.23 ius-archive php56u-5.6.23 php56u-5.6.23-1.ius.centos7
5.6.22 ius-archive php56u-5.6.22 php56u-5.6.22-2.ius.centos7
5.6.21 ius-archive php56u-5.6.21 php56u-5.6.21-1.ius.centos7
5.6.20 ius-archive php56u-5.6.20 php56u-5.6.20-1.ius.centos7

Atomic リポジトリ

PHP リポジトリ パッケージ名 ビルド日 バージョン
7.0.8 atomic atomic-php70-php 7.0.8-9.el7.art
5.6.23 atomic atomic-php56-php 5.6.23-38.el7.art
5.5.37 atomic atomic-php55-php 5.5.37-37.el7.art
5.4.45 atomic atomic-php54-php 5.4.45-54.el7.art
5.4.45 atomic php 5.4.45-54.el7.art
yum install https://www.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/atomic-release-1.0-21.el7.art.noarch.rpm
yum install php

Archives

PHP リポジトリ パッケージ名 バージョン
5.6.23 atomic atomic-php56-php-5.6.23-38.el7.art 5.6.23-38.el7.art
5.6.22 atomic atomic-php56-php-5.6.22-37.el7.art 5.6.22-37.el7.art
5.6.21 atomic atomic-php56-php-5.6.21-36.el7.art 5.6.21-36.el7.art
5.6.20 atomic atomic-php56-php-5.6.20-35.el7.art 5.6.20-35.el7.art
5.6.19 atomic atomic-php56-php-5.6.19-34.el7.art 5.6.19-34.el7.art
5.6.18 atomic atomic-php56-php-5.6.18-33.el7.art 5.6.18-33.el7.art
5.6.17 atomic atomic-php56-php-5.6.17-32.el7.art 5.6.17-32.el7.art
5.6.16 atomic atomic-php56-php-5.6.16-31.el7.art 5.6.16-31.el7.art
5.6.15 atomic atomic-php56-php-5.6.15-30.el7.art 5.6.15-30.el7.art
5.6.14 atomic atomic-php56-php-5.6.14-29.el7.art 5.6.14-29.el7.art
5.6.13 atomic atomic-php56-php-5.6.13-27.el7.art 5.6.13-27.el7.art
5.6.12 atomic atomic-php56-php-5.6.12-28.el7.art 5.6.12-28.el7.art
5.6.11 atomic atomic-php56-php-5.6.11-26.el7.art 5.6.11-26.el7.art
5.5.37 atomic atomic-php55-php-5.5.37-37.el7.art 5.5.37-37.el7.art
5.5.36 atomic atomic-php55-php-5.5.36-36.el7.art 5.5.36-36.el7.art
5.5.35 atomic atomic-php55-php-5.5.35-35.el7.art 5.5.35-35.el7.art
5.5.34 atomic atomic-php55-php-5.5.34-34.el7.art 5.5.34-34.el7.art
5.5.33 atomic atomic-php55-php-5.5.33-33.el7.art 5.5.33-33.el7.art
5.5.32 atomic atomic-php55-php-5.5.32-32.el7.art 5.5.32-32.el7.art
5.5.31 atomic atomic-php55-php-5.5.31-31.el7.art 5.5.31-31.el7.art
5.5.30 atomic atomic-php55-php-5.5.30-30.el7.art 5.5.30-30.el7.art
5.4.45 atomic atomic-php54-php-5.4.45-54.el7.art 5.4.45-54.el7.art
5.4.45 atomic atomic-php54-php-5.4.45-53.el7.art 5.4.45-53.el7.art
5.4.45 atomic atomic-php54-php-5.4.45-52.el7.art 5.4.45-52.el7.art
5.4.45 atomic atomic-php54-php-5.4.45-51.el7.art 5.4.45-51.el7.art
5.4.44 atomic php-5.4.44 5.4.44-50.el7.art
5.4.43 atomic php-5.4.43 5.4.43-49.el7.art
5.4.42 atomic php-5.4.42 5.4.42-48.el7.art

Webtatic リポジトリ

PHP リポジトリ パッケージ名 ビルド日 バージョン
7.0.8 webtatic php70w 2016-06-23 7.0.8-1.w6
5.6.23 webtatic php56w 2016-06-23 5.6.23-1.w6
5.5.37 webtatic php55w 2016-06-23 5.5.37-1.w6
5.4.45 webtatic php54w 2015-10-16 5.4.45-2.w6
yum install https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php

PHP 関連記事

122
146
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
122
146