dnf module switch-to でストリームを変更する
『AlmaLinux 9 に PHP をインストールする』や『RemiリポジトリからPHP8.3をインストールする』でインストールした PHP のバージョンをアップグレードしたいんだけど?ってときは dnf module switch-to から、モジュールのストリームを切り替えることで実現できます。めっちゃ簡単で便利!!
11.5. 後のストリームへの切り替え | Red Hat Product Documentation
11.5. 後のストリームへの切り替え | Red Hat Documentation
んじゃ、実際にやってみましょう。
前提
- OS は今回も AlmaLinux 9.5 です
- PHPは AppStream リポジトリの PHP8.2 が最小構成で入ってる状態とします
- AppStream リポジトリの PHP8.2 から Remi リポジトリの PHP8.3 に切り替えます
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 | php -v PHP 8.2.13 (cli) (built: Nov 21 2023 09:55:59) (NTS gcc x86_64) Copyright (c) The PHP Group Zend Engine v4.2.13, Copyright (c) Zend Technologies dnf module list php AlmaLinux 9 - AppStream Name Stream Profiles Summary php 8.1 common [d], devel, minimal PHP scripting language php 8.2 [e] common [d], devel, minimal [i] PHP scripting language Remi's Modular repository for Enterprise Linux 9 - x86_64 Name Stream Profiles Summary 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 common [d], devel, minimal PHP scripting language Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled |
dnf module switch-to php:remi-8.3
モジュールの入れ替えになるんで root 権限なり sudo で実行する形は必要なんですが、見出しの 1コマンドで終わります。
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | sudo dnf module -y switch-to php:remi-8.3 Last metadata expiration check: 0:12:34 ago on Thu 12 Sep 2024 01:49:36 PM UTC. Dependencies resolved. ==================================================================================================================================== Package Architecture Version Repository Size ==================================================================================================================================== Upgrading: php-cli x86_64 8.3.11-1.el9.remi remi-modular 5.6 M php-common x86_64 8.3.11-1.el9.remi remi-modular 1.2 M Switching module streams: php 8.2 -> remi-8.3 Transaction Summary ==================================================================================================================================== Upgrade 2 Packages Total download size: 6.8 M Downloading Packages: (1/2): php-common-8.3.11-1.el9.remi.x86_64.rpm 160 kB/s | 1.2 MB 00:07 (2/2): php-cli-8.3.11-1.el9.remi.x86_64.rpm 330 kB/s | 5.6 MB 00:17 ------------------------------------------------------------------------------------------------------------------------------------ Total 387 kB/s | 6.8 MB 00:18 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: php-common-8.3.11-1.el9.remi.x86_64 1/4 Upgrading : php-common-8.3.11-1.el9.remi.x86_64 1/4 Upgrading : php-cli-8.3.11-1.el9.remi.x86_64 2/4 Cleanup : php-cli-8.2.13-1.module_el9.4.0+65+49ff6472.x86_64 3/4 Cleanup : php-common-8.2.13-1.module_el9.4.0+65+49ff6472.x86_64 4/4 Running scriptlet: php-common-8.2.13-1.module_el9.4.0+65+49ff6472.x86_64 4/4 Verifying : php-cli-8.3.11-1.el9.remi.x86_64 1/4 Verifying : php-cli-8.2.13-1.module_el9.4.0+65+49ff6472.x86_64 2/4 Verifying : php-common-8.3.11-1.el9.remi.x86_64 3/4 Verifying : php-common-8.2.13-1.module_el9.4.0+65+49ff6472.x86_64 4/4 Upgraded: php-cli-8.3.11-1.el9.remi.x86_64 php-common-8.3.11-1.el9.remi.x86_64 Complete! |
確認してみましょう。
1 2 3 4 5 | php -v PHP 8.3.11 (cli) (built: Aug 27 2024 19:16:34) (NTS gcc x86_64) Copyright (c) The PHP Group Zend Engine v4.3.11, Copyright (c) Zend Technologies |
PHP のバージョンはちゃんと切り替わっています。
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 | dnf module list php Last metadata expiration check: 0:13:36 ago on Thu 12 Sep 2024 01:52:59 PM UTC. AlmaLinux 9 - AppStream Name Stream Profiles Summary php 8.1 common [d], devel, minimal PHP scripting language php 8.2 common [d], devel, minimal PHP scripting language Remi's Modular repository for Enterprise Linux 9 - x86_64 Name Stream Profiles Summary 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], devel, minimal [i] PHP scripting language Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled |
ストリームも Remi リポジトリの remi-8.3 に変わってますね。プロファイルも切り替え前が minimal だったので、切替後も minimal となります。
一応、dnf module reset でストリームの選択をリセットしてから、dnf module enable php:remi-8.3 → dnf module install php/minimal と手動でインストールしても同じことができるんですが、コマンド一発で解決すると簡単でとても良いです!!