如何在CentOS下更新php版本2018-11-13

1. 首先先看下已安装的版本:

yum list installed | grep php

可以看到我的都是5.3的

php.x86_64              5.3.3-48.el6_8  @updates                                

php-cli.x86_64          5.3.3-48.el6_8  @updates                                

php-common.x86_64       5.3.3-48.el6_8  @updates                                

php-fpm.x86_64          5.3.3-48.el6_8  @updates                                

php-gd.x86_64           5.3.3-48.el6_8  @updates                                

php-mysql.x86_64        5.3.3-48.el6_8  @updates                                

php-pdo.x86_64          5.3.3-48.el6_8  @updates

2. 升级之前需要卸载一下旧版本,不卸载直接安装新版会提示失败:

yum remove php php-common

我的就卸载了以上两个就ok了

3. 然后更新一下yum源:

rpm-Uvhhttps://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

4. 最后安装 5.6版 php 和 php-fpm 以及一些其他扩展,按需选择

yum install php56w php56w-fpm php56w-mysql php56w-mbstring php56w-gd php56w-dom

其中 php-fpm 是 nginx 里要用的 fast-cgi 进程管理器,重新安装后可能还需要重启一下fpm

/etc/init.d/php-fpm restart

重启service httpd restart


Php yum

 

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