在 AlmaLinux 9 上,預設 OS AppStream 儲存庫中沒有 PHP 8.1 套件。預設情況下,我們的 AlmaLinux 上可安裝的 PHP 版本是 PHP 8.0,因此要取得較新的版本(例如 PHP 8.1),我們需要新增/啟用第三方儲存庫(例如 Remi)。 要安裝 PHP 8.1,我們需要新增/啟用包含我們需要的 PHP 8.1 套件的 Remi RPM 儲存庫。 先決條件: 安裝並運行 AlmaLinux 9 的系統。 - 系統的 root 存取權限。
首先,讓我們確保您的系統是最新的。
安裝 EPEL 和 Remi 儲存庫
為此,我們使用 Remi 打包的 PHP 7.4 和 8.1, 首先,讓我們安裝 EPEL 儲存庫, - dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
複製代碼
接下來,使用以下命令安裝 Remi 儲存庫 - dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
複製代碼
列出可用的 PHP 模組流
若要檢查/列出可用的 PHP 版本,請使用下列命令 - [root@server ~]# dnf module list php
- Remi's Modular repository for Enterprise Linux 4.7 kB/s | 833 B 00:00
- Remi's Modular repository for Enterprise Linux 3.0 MB/s | 3.1 kB 00:00
- Importing GPG key 0x478F8947:
- Userid : "Remi's RPM repository (https://rpms.remirepo.net/) <remi@remirepo.net>"
- Fingerprint: B1AB F71E 14C9 D748 97E1 98A8 B195 27F1 478F 8947
- From : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9
- Is this ok [y/N]: y
- Remi's Modular repository for Enterprise Linux 2.6 MB/s | 545 kB 00:00
- Safe Remi's RPM repository for Enterprise Linux 6.9 kB/s | 833 B 00:00
- Safe Remi's RPM repository for Enterprise Linux 3.0 MB/s | 3.1 kB 00:00
- Importing GPG key 0x478F8947:
- Userid : "Remi's RPM repository (https://rpms.remirepo.net/) <remi@remirepo.net>"
- Fingerprint: B1AB F71E 14C9 D748 97E1 98A8 B195 27F1 478F 8947
- From : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9
- Is this ok [y/N]: y
- Safe Remi's RPM repository for Enterprise Linux 3.1 MB/s | 700 kB 00:00
- 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
- Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
複製代碼
現在,讓我們透過 remi 儲存庫安裝 PHP 7.4- dnf module install php:remi-7.4
複製代碼
現在我們已經透過 remi 儲存庫安裝了 PHP 7.4,我們可以透過執行以下命令來驗證安裝的版本php -v
Alamlinux PHP
如要修改安裝PHP 8.0版本- dnf module reset php
- dnf module install php:remi-8.0
複製代碼
重新開機後- dnf module enable php:remi-8.0
- dnf install -y php php-cli php-common
- php -v
複製代碼
Alamlinux PHP
https://wiki.crowncloud.net/?How_to_Install_PHP_7_4_or_8_1_in_AlmaLinux_9
https://blog.yucas.net/2021/11/23/error-it-is-not-possible-to-switch-enabled-streams-of-a-module-unless-explicitly-enabled-via-configuration-option-module_stream_switch-php/
https://reintech.io/blog/installing-php-8-almalinux-9
|