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

PHP8(PHP-FPM)のメモ

$
0
0

環境

  • CentOS7
    (元々色々なバージョンを動かすのに使ってた)

epel, remi のリポジトリの追加は済んでる環境(下記)

yum -yinstall epel-release
yum -yinstall http://rpms.remirepo.net/enterprise/remi-release-7.rpm

PHP8と諸々インストール

yum -yinstall php80 php80-php php80-php-mbstring php80-php-pdo php80-php-mysqlnd php80-php-gd php80-php-xml php80-php-fpm

設定

cd /etc/opt/remi/php80/php-fpm.d/
cp-a www.conf www.conf-original
vi www.conf
www.conf
listen = 127.0.0.1:9080
pm = ondemand

いろんなバージョンのPHPを動かしているのでポートはそれぞれ被らないように設定

vi /etc/httpd/conf.d/virtualhost.conf
virtualhost.conf
<Directory "/path/to/php80/document_root"><FilesMatch \.php$>
                        SetHandler "proxy:fcgi://localhost:9080"# ← www.conf に指定したポート番号</FilesMatch>
        </Directory>

更新して起動する

service httpd configtest
systemctl start php80-php-fpm
systemctl status php80-php-fpm
systemctl enable php80-php-fpm
systemctl restart httpd

おわり。

Apacheのデフォルトで使用されるバージョンを変える

正解かどうかわからないけど、
PHPのバージョンごとにあるApacheのモジュールを無効化すればOK。

リネームなり削除して読み込まれるモジュールを変える。
なお、複数生きている場合はファイル名昇順で先に来るものが当たる(たぶん)
※ パッケージ更新すると復活するかも…

cd /etc/httpd/conf.modules.d
mv 15-php72-php.conf 15-php72-php.conf_bak
systemctl restart httpd

PHP7のソースをPHP8で動かしてみて引っかかったところと変更内容

自動DIで使ってたリフレクションの一部がコケた

// ↓ NGになった$tempReflectionClass=$reflectionParameter->getClass();// ↓ OK$type=$reflectionParameter->getType();$tempReflectionClass=$type!==null&&!$type->isBuiltin()?new\ReflectionClass($type->getName()):null;

is_callable を静的でないクラスメソッドに対して
クラス名とメソッド名で読んでいたのがNGになった。

// ↓ NGになったis_callable([クラス名,静的でないメソッド名]);// ↓ OKis_callable([インスタンス,静的でないメソッド名]);

Viewing all articles
Browse latest Browse all 544

Trending Articles