一、检查当前安装的PHP包
yum list installed | grep php
如果有安装的PHP包,先删除他们, 如:
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64
二、配置安装包源
# Centos 5.X
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
# CentOs 6.x
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
# CentOs 7.X
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
如果想删除上面安装过的包,重新安装
rpm -qa | grep webstatic
rpm -e [上面搜索到的包即可]
三、安装
yum -y install php56w.x86_64
yum -y --enablerepo=webtatic install php56w-devel
yum -y install php56w-pdo php56w-xml php56w-gd php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-opcache.x86_64
注:安装时出现error:
Error: Package: php56w-mcrypt-5.6.40-1.w6.x86_64 (webtatic)
Requires: libmcrypt.so.4()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
解决方法:
安装 epel-release 源即可解决
yum install epel-release -y
然后执行命令安装 libmcrypt
yum install libmcrypt libmcrypt-devel -y
四、安装php fpm
yum -y install php56w-fpm
#设置php-fpm开机启动
chkconfig php-fpm on
#启动php-fpm
/etc/init.d/php-fpm start