ゆう’s blog

のんびり色々、アプリ、Web開発やら日常やら。

CentOS7にPHP7.2.xをインストールする

CentOS7にPHP7.2.xをインストールしたのでメモ

リポジトリの追加

PHPを標準のリポジトリからではなく、他のところから取得するので、
以下のコマンドを入力し、EPELとREMIのリポジトリを追加します。

$ sudo yum install epel-release
$ sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

追加されたか確認します。
EPEL, Remi のリポジトリが追加されています。
※remi-php72.repoに注目

$ ls -l /etc/yum.repos.d/
total 60
-rw-r--r--. 1 root root 1664 Aug 30  2017 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Aug 30  2017 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Aug 30  2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  630 Aug 30  2017 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Aug 30  2017 CentOS-Sources.repo
-rw-r--r--. 1 root root 3830 Aug 30  2017 CentOS-Vault.repo
-rw-r--r--. 1 root root  314 Aug 30  2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 1056 Dec 27  2016 epel-testing.repo
-rw-r--r--. 1 root root  957 Dec 27  2016 epel.repo
-rw-r--r--. 1 root root  456 Mar 21 13:28 remi-php54.repo
-rw-r--r--. 1 root root 1314 Mar 21 13:28 remi-php70.repo
-rw-r--r--. 1 root root 1314 Mar 21 13:28 remi-php71.repo
-rw-r--r--. 1 root root 1314 Mar 21 13:28 remi-php72.repo
-rw-r--r--. 1 root root  750 Mar 21 13:28 remi-safe.repo
-rw-r--r--. 1 root root 2605 Mar 21 13:28 remi.repo

PHP 7.2 のインストール

以下のコマンドを入力し、インストールします。
なお、利用するアプリケーションに合わせて、追加で mbstring などの PHP の拡張をインストールします。

$ sudo yum install --disablerepo=* --enablerepo=epel,remi,remi-php72 php php-mbstring php-mysql php-intl

Requires: /usr/sbin/semanage とエラーが出たら以下のコマンドを実行する

$ yum provides /usr/sbin/semanage

$ sudo yum -y install policycoreutils-python-xx.xx

Requires: libtcl8.5.so()(64bit) とエラーが出たら以下のコマンドを実行する
※他にエラーがあれば同様に解決していく

$ sudo yum whatprovides libtcl8.5.so

$ sudo yum -y install tcl


以上です。