在CentOS上进行PHP版本控制,您可以使用Remi或RPM Fusion存储库来安装和管理多个PHP版本
方法1:使用Remi存储库
sudo yum install epel-release yum-utils
sudo yum-config-manager --add-repo https://rpms.remirepo.net/enterprise/remi-release-7.rpm
请注意,上面的命令适用于CentOS 7。如果您使用的是CentOS 8,请将URL更改为适用于CentOS 8的URL。
yum --enablerepo=remi list available php\*
sudo yum --enablerepo=remi install php74-php
php -v
方法2:使用RPM Fusion存储库
对于CentOS 7:
sudo yum install epel-release yum-utils
sudo yum-config-manager --add-repo https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
sudo yum-config-manager --add-repo https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
对于CentOS 8:
sudo dnf install dnf-plugins-core
sudo dnf config-manager --add-repo https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm
sudo dnf config-manager --add-repo https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm
yum list available php\*
sudo yum install php74-php
php -v
现在,您已经在CentOS上安装了所需的PHP版本。如果您需要切换到其他版本,只需重复上述步骤并安装所需的版本。