OS標準のインストール
最新版でもphp8.2となりEOLが過ぎているため
remiでインストールする
前準備
EPELパッケージをインストール
$ sudo dnf install dnf-utils epel-release
remiのphpインストール
dnfコマンドでレポジトリをインストール。末尾の数値はOSのバージョンに合わせる。
Rocky Linux 8ならremi-release-8.rpm
$ sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
$ sudo dnf module list php
Rocky Linux 8 - AppStream
Name Stream Profiles Summary
php 7.2 [d] common [d], devel, minimal PHP scripting language
php 7.3 common [d], devel, minimal PHP scripting language
php 7.4 common [d], devel, minimal PHP scripting language
php 8.0 common [d], devel, minimal PHP scripting language
php 8.2 common [d], devel, minimal PHP scripting language
Remi's Modular repository for Enterprise Linux 8 - x86_64
Name Stream Profiles Summary
php remi-7.2 common [d], devel, minimal PHP scripting language
php remi-7.3 common [d], devel, minimal PHP scripting language
php remi-7.4 common [d], devel, minimal PHP scripting language
php remi-8.0 common [d], devel, minimal PHP scripting language
php remi-8.1 common [d], devel, minimal PHP scripting language
php remi-8.2 common [d], devel, minimal PHP scripting language
php remi-8.3 [e] common [d] [i], devel, minimal PHP scripting language
php remi-8.4 common [d], devel, minimal PHP scripting language
php remi-8.5 common [d], devel, minimal PHP scripting language
ヒント: [d]efault, [e]nabled, [x]disabled, [i]nstalled
php8.4を有効にする
$ sudo dnf module reset php -y
$ sudo dnf module enable php:remi-8.4
$ sudo dnf module install php:remi-8.4
php8.3から8.4にする場合はswitch-toオプションで指定する
$ sudo dnf module switch-to php:remi-8.4
確認
$ php -v
PHP 8.4.14 (cli) (built: Oct 21 2025 19:23:55) (NTS gcc x86_64)
Copyright (c) The PHP Group
Built by Remi's RPM repository <https://rpms.remirepo.net/> #StandWithUkraine
Zend Engine v4.4.14, Copyright (c) Zend Technologies
with Zend OPcache v8.4.14, Copyright (c), by Zend Technologies