PHP7.2のインストール

PHP7.2のインストールを行います。

1. PHPのインストール

(1) phpのインストール
yumでインストールを行います。
# yum install --enablerepo=epel,remi,remi-php72 php

(2) php-develのインストール
※php-develのインストールは任意です。
yumでインストールを行いますが、7.2.3以降では前提条件として「devtoolset-6-gcc」がインストールされている必要があります。
そこで、まず「devtoolset-6」をインストールします。
※PHP 7.2.3未満の場合は「devtoolset-6」のインストールは不要です。
# yum install centos-release-scl
# yum install yum-utils
# yum-config-manager --enable rhel-server-rhscl-7-rpms
# yum install devtoolset-6

php-develをインストールします。
# yum install --enablerepo=remi,remi-php72 php-devel

元の環境に戻します。
# yum-config-manager --disable rhel-server-rhscl-7-rpms


2. libmcryptのインストール

# yum install --enablerepo=epel libmcrypt

3. phpのモジュールのインストール

これは任意ですが、必要なモジュールをインストールします。
# yum install --enablerepo=remi,remi-php72 php-mysqlnd
# yum install --enablerepo=remi,remi-php72 php-mbstring
# yum install --enablerepo=remi,remi-php72 php-gd
# yum install --enablerepo=remi,remi-php72 php-xml
# yum install --enablerepo=remi,remi-php72 php-xmlrpc
# yum install --enablerepo=remi,remi-php72 php-pecl-mcrypt
# yum install --enablerepo=remi,remi-php72 php-fpm
# yum install --enablerepo=remi,remi-php72 php-opcache
# yum install --enablerepo=remi,remi-php72 php-apcu
# yum install --enablerepo=remi,remi-php72 php-zip
# yum install --enablerepo=remi,remi-php72 php-pear
※従来の「php-mcrypt」は7.2から「php-pecl-mcrypt」になりました。

4. /etc/php.iniの編集

(1) エラーログファイルの作成
「/var/log/httpd/php_errors.log」というファイルを作成しておきます。
# touch /var/log/httpd/php_errors.log
# chmod 777 /var/log/httpd/php_errors.log

(2) php.iniの編集
# vi /etc/php.ini

expose_php = Off
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
error_log = /var/log/httpd/php_errors.log

post_max_size = 20M
upload_max_filesize = 20M
date.timezone = "Asia/Tokyo"
session.gc_divisor = 100
session.gc_maxlifetime = 3600
mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.http_input = pass
mbstring.http_output = pass

(2) Apacheの再起動
Apacheを再起動して、PHPを有効にします。
# systemctl restart httpd.service

5. php-fpmサービスの起動

# systemctl enable php-fpm.service
# systemctl restart php-fpm.service



最終更新:2018年11月01日 11:49