啟用軟體倉庫

啟用 Remi 和 EPEL 軟體倉庫 (repository):

dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm




安裝 PHP 指定或最新版本

取得所有可安裝的 PHP 版本列表,預設的版本為 PHP 7.2:

dnf module list php

Extra Packages for Enterprise Linux Modular 8 - x86_64                                                           39 kB/s | 116 kB     00:02
Extra Packages for Enterprise Linux 8 - x86_64                                                                  1.2 MB/s | 6.2 MB     00:05
Remi's Modular repository for Enterprise Linux 8 - x86_64                                                        20 kB/s | 540 kB     00:27
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                                                       31 kB/s | 1.4 MB     00:45
CentOS-8 - AppStream
Name                      Stream                       Profiles                                       Summary
php                       7.2 [d]                      common [d], devel, minimal                     PHP scripting language
php                       7.3                          common, 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

提示:預設[d]、已啟用[e]、已停用[x]、已安裝[i]

依據上述 PHP 列表來啟用要安裝的 PHP 版本,這裡啟用 PHP 7.4:

dnf module reset php

dnf module enable php:remi-7.4

安裝:

dnf install php

參考來源:

https://www.footmark.com.tw/news/linux/centos/centos-8-yum-php-mainline/
最後修改日期: 2022-11-20

作者

留言

撰寫回覆或留言