一、卸载php7.2
yum remove php*
需要将centos的yum源更新
二、源报错问题或者yum源不是最新请执行一下命令
Error: Failed to download metadata for repo ‘appstream’: Cannot prepare interna
#进入yum源目录
cd /etc/yum.repos.d
替换yum配置
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
#备份yum配置
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
#下载最新yum配置
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
三、安装remi存储库
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
若报错:
Error:
Problem: conflicting requests
- nothing provides redhat-release >= 8.6 needed by remi-release-8.6-1.el8.remi.noarch
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
解决:
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-8.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-8.rpm
rpm -ivh remi-release-8.rpm
四、安装EPEL存储库
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
五、安装好EPEL和Remi存储库后,执行以下命令以获取可用PHP模块流的列表
dnf module list php
[e]nabled, [x]disabled, [i]nstalled
如果没有php74更新下源库
dnf update
dnf makecache
六、启用php74模块流
dnf module reset php
dnf module enable php:remi-7.4
七、安装php74
dnf install php php-cli php-common
php -v