1、先查看已安装相关PHP
rpm -qa |grep PHP
2、卸载已安装相关PHP
yum remove PHP
3、添加第三方源
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
4、编辑[remi.repo]下的enabled选项从0设为1
执行sed -i '/enabled/s/=0/=1/g' /etc/yum.repos.d/remi.repo
5、运行以下命令
yum clean all
yum makecache
7、安装PHP5.6
7.1、yum -y install PHP56PHP56-PHP-fpmPHP56-PHP-MysqL
7.2、如果报错安装运行yum报错解决方法:
Error: Cannot retrieve Metalink for repository: epel. Please verify its path and try again
编辑[epel.repo]下的baseurl前的#号去掉,mirrorlist前添加#号
执行sed 's/#baseurl=/baseurl=/g;s/mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/epel.repo
原文链接:https://www.f2er.com/centos/378853.html