3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

RedHat 8.8(RHEL 8系)で PHP を 8.0 → 8.2 にアップグレードする

Last updated at Posted at 2025-12-08

概要

RedHatのPHPのバージョンアップする手順を紹介します。

  • OS:RedHat 8.8
  • PHP:8.0.30

手順

PHPのバージョンを確認

php
php -v

対象バージョンのモジュールがすでに存在するか確認

dnf module list php

下記のように表示され、現在のバージョンに [e] が付いていると思います。

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 [e] 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 common [d], 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 
Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs) 
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

今回は8.2に上げたいので、remi-8.2があればOKです。
もし、8系が無い場合、Remi リポジトリをインストールします。

sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm

現在登録されているパッケージの確認とバックアップ

dnf list installed | grep php

php- と表示されている項目が、現在のバージョンになっていると思います。
下記コマンドで、txt形式で残しておきましょう。

dnf list installed | grep php > current_php_packages.txt

PHP 8.2 の拡張と比較するのに便利です。
また、etcディレクトリ内にあるphp関連のファイルをコピーしておくと安心です。
※php.iniなど

現在のPHPモジュールを無効化

sudo dnf module reset php -y

-y は実行確認で「yes」を選択するためつけています。

PHP8.2モジュールを有効化

sudo dnf module enable php:remi-8.2 -y

PHP8.2のパッケージをインストール

「dnf list installed | grep php」で確認したものをインストールしていきます。

sudo dnf install php php-cli php-common php-fpm php-devel php-gd php-mbstring php-mysqlnd php-opcache php-pdo php-process php-sodium php-xml

php-fpm / Nginx 再起動

sudo systemctl restart php-fpm
sudo systemctl restart nginx

PHPのバージョン確認

最後にバージョンを確認しましょう。

php
php -v
dnf list installed | grep php

また、php.iniは旧バージョンのものが維持されます。
必要に応じて新バージョンのphp.iniに切り替えや、設定の変更をしてください。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?