找回密碼
 註冊
搜索
查看: 338|回復: 0

[AlamLinux] Alamlinux 9 如何安裝 PHP 7.4

[複製鏈接]
發表於 2025-2-28 11:59:12 | 顯示全部樓層 |閱讀模式
 
Push to Facebook
在 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 存取權限。

首先,讓我們確保您的系統是最新的。
  1. dnf update
複製代碼



安裝 EPEL 和 Remi 儲存庫
為此,我們使用 Remi 打包的 PHP 7.4 和 8.1,
首先,讓我們安裝 EPEL 儲存庫,
  1. dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
複製代碼

接下來,使用以下命令安裝 Remi 儲存庫
  1. dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
複製代碼


列出可用的 PHP 模組流
若要檢查/列出可用的 PHP 版本,請使用下列命令
  1. dnf module list php
複製代碼

  1. [root@server ~]# dnf module list php
  2. Remi's Modular repository for Enterprise Linux  4.7 kB/s | 833  B     00:00
  3. Remi's Modular repository for Enterprise Linux  3.0 MB/s | 3.1 kB     00:00
  4. Importing GPG key 0x478F8947:
  5. Userid     : "Remi's RPM repository (https://rpms.remirepo.net/) <remi@remirepo.net>"
  6. Fingerprint: B1AB F71E 14C9 D748 97E1 98A8 B195 27F1 478F 8947
  7. From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9
  8. Is this ok [y/N]: y
  9. Remi's Modular repository for Enterprise Linux  2.6 MB/s | 545 kB     00:00
  10. Safe Remi's RPM repository for Enterprise Linux 6.9 kB/s | 833  B     00:00
  11. Safe Remi's RPM repository for Enterprise Linux 3.0 MB/s | 3.1 kB     00:00
  12. Importing GPG key 0x478F8947:
  13. Userid     : "Remi's RPM repository (https://rpms.remirepo.net/) <remi@remirepo.net>"
  14. Fingerprint: B1AB F71E 14C9 D748 97E1 98A8 B195 27F1 478F 8947
  15. From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9
  16. Is this ok [y/N]: y
  17. Safe Remi's RPM repository for Enterprise Linux 3.1 MB/s | 700 kB     00:00
  18. Remi's Modular repository for Enterprise Linux 9 - x86_64
  19. Name      Stream       Profiles                       Summary
  20. php       remi-7.4     common [d], devel, minimal     PHP scripting language
  21. php       remi-8.0     common [d], devel, minimal     PHP scripting language
  22. php       remi-8.1     common [d], devel, minimal     PHP scripting language

  23. Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
複製代碼

現在,讓我們透過 remi 儲存庫安裝 PHP 7.4
  1. dnf module install php:remi-7.4
複製代碼



現在我們已經透過 remi 儲存庫安裝了 PHP 7.4,我們可以透過執行以下命令來驗證安裝的版本php -v
  1. php -v
複製代碼

Alamlinux PHP

Alamlinux  PHP



如要修改安裝PHP 8.0版本
  1. dnf module reset php
  2. dnf module install php:remi-8.0
複製代碼

重新開機後
  1. dnf module enable php:remi-8.0
  2. dnf install -y php php-cli php-common
  3. php -v
複製代碼

Alamlinux PHP

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
 
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|小黑屋|TShopping

GMT+8, 2025-6-15 17:06 , Processed in 0.027059 second(s), 24 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回復 返回頂部 返回列表