Quantcast
Channel: PHP8タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 521

CentOS8にベータ版php8.0をインストールする方法

$
0
0

経緯

php8.0が2020年11月26日にリリースされる予定らしい。
remi氏のリポジトリでもベータ版が出ているのでインストールして動作確認する。

インストール方法

百番煎じくらいの、CentOS8でPHP8環境作るコピペ
Centos8 php8.0をインストールする方法
php80-php-8.0.0~beta4-32.el8.remi.x86_64.rpm

phpの本体を入れる。

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf install yum-utils
dnf --enablerepo=remi install php80-php

データベースの接続も試したいのでmariadbを入れる

dnf install mariadb-server
systemctl start mariadb.service
mysql_secure_installation

phpのモジュールを入れる。

dnf install --enablerepo=remi php80-php-mysqlnd php80-php-mysqli php80-php-gd php80-php-cli php80-php-opcache
dnf install --enablerepo=remi php80-php-pecl-zip php80-php-devel php80-php-pear

php、pear、peclなどのコマンドはインストールするだけではパスが通らないので、findで探してフルパスで呼び出す。

find / -name pear
find / -name pecl
/opt/remi/php80/root/usr/bin/pecl install APCu
/opt/remi/php80/root/usr/bin/pear install Mail_MimeDecode
/opt/remi/php80/root/usr/bin/pear install HTTP_Client
/opt/remi/php80/root/usr/bin/pear install Net_IPv6

alternativesを利用してバージョンを切り替えると上品だけど、今回はテストなのでしない。
複数のバージョンの PHP を切り替えて使う

httpdとphpを起動。最近はphp-fpmが入るのが普通らしい。

systemctl start httpd.service
systemctl start php80-php-fpm.service

phpinfo();を実行し「Loaded Configuration File」を調べてphp.iniのパスを確認する。
php_ini.png
php.iniに追記。

php.ini
extension=apcu.so

phpを再起動。

systemctl restart php80-php-fpm.service

結果

gdやmysqliは異常なし。
OPcacheもapcuも普通に動いてる。
Net_IPv6がFatal errorを吐くので修正。

/opt/remi/php80/root/usr/share/pear/Net/IPv6.php
# 806行目付近#            $ip{$pos} = '_'; #修正前$ip[$pos]='_';#修正後

Viewing all articles
Browse latest Browse all 521

Trending Articles