CentOS 7.6でPHP 5.6を扱う

CentOS 7.6ではPHPは5.4が標準

PHP 5.6のEOLは2019年なので残り僅かだが、CentOS 7.6では5.4が標準である。セキュリティ問題はバックポートされているので心配ないが、バージョン番号だけをみてインストール可否をしているパッケージがあるので(たとえばWordpress)、とりあえず5.6にあげておきたい。最新はPHP 7.1ですかね。epelのレポジトリをインストールされていること前提で手順を進めます。

レポジトリをインストール
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

ポイント:remiのレポジトリはデフォルトでdisableになっているので利用時は enablerepoする。
PHP5.6がレポジトリにあるか確認
# yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
ずらっとでてくればOK

ではインストール
ポイント:"epelもenablerepoにしている" 依存するライブラリがepelにあるのだ(libmcrypt)
# yum install --enablerepo=epel --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof

バージョンアップされていることを確認
# php --version
PHP 5.6.40 (cli) (built: Apr 30 2019 11:35:35) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans