PHP7.4のインストール【Amazon Linux 2】
Amazon Linux 2のamazon-linux-extrasはPHP7.3までなので、php7.4はremi-php74を使用して通常通りにインストールします。
1. PHPのインストール
(1) リポジトリのインストール
(2) phpのインストール
yumでインストールを行います。
# yum install --enablerepo=epel,remi,remi-php74 php74
(3) php-develのインストール
※php-develのインストールは任意です。
# yum install --enablerepo=epel,remi,remi-php74 php74-devel
2. 関連モジュールのインストール
(1) libmcryptのインストール
# yum install --enablerepo=epel libmcrypt
(2) libargon2のインストール
php-pdoをインストールする場合に必要です。
# yum install --enablerepo=epel libargon2
# yum install --enablerepo=epel libargon2-devel
3. phpのモジュールのインストール
これは任意ですが、必要なモジュールをインストールします。
# yum install --enablerepo=remi,remi-php73 php-mysqlnd
# yum install --enablerepo=remi,remi-php73 php-mbstring
# yum install --enablerepo=remi,remi-php73 php-gd
# yum install --enablerepo=remi,remi-php73 php-xml
# yum install --enablerepo=remi,remi-php73 php-xmlrpc
# yum install --enablerepo=remi,remi-php73 php-pecl-mcrypt
# yum install --enablerepo=remi,remi-php73 php-fpm
# yum install --enablerepo=remi,remi-php73 php-opcache
# yum install --enablerepo=remi,remi-php73 php-apcu
# yum install --enablerepo=remi,remi-php73 php-zip
# yum install --enablerepo=remi,remi-php73 php-pdo
# yum install --enablerepo=remi,remi-php73 php-pear
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の編集
upload_max_filesize = 20M
date.timezone = "Asia/Tokyo"
session.gc_maxlifetime = 3600
mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.http_input = pass
mbstring.http_output = pass
(2) pearモジュールのインストール
必要に応じて、PEARのモジュールをインストールします。
【例】PEAR Mailモジュールのインストール。
※「-a」オプションを付けると、依存ファイルもすべてインストールします。
(3) Apacheの再起動
Apacheを再起動して、PHPを有効にします。
# systemctl restart httpd.service
5. php-fpmサービスの起動
# systemctl enable php-fpm.service
# systemctl start php-fpm.service
最終更新:2020年02月10日 17:36