我用的centOs6.8,可是默认php版本是5.3,我觉得版本太低,故将其卸载重装php5.6版本
1.检查当前安装的PHP包 **
这个命令是删除不干净的
#yum remove php 因为使用这个命令以后再用
#php -v 还是会看到有版本信息的。。。。。
必须强制删除
#rpm -qa|grep php 提示如下
#php-pdo-5.1.6-27.el5_5.3
#php-MySQL-5.1.6-27.el5_5.3
#php-xml-5.1.6-27.el5_5.3
#php-cli-5.1.6-27.el5_5.3
#php-common-5.1.6-27.el5_5.3
#php-gd-5.1.6-27.el5_5.3 注意卸载要先卸载没有依赖的 pdo是mysql的依赖项;common是gd的依赖项; 例如:# rpm -e php-pdo-5.1.6-27.el5_5.3
error: Failed dependencies:php-pdo is needed by (installed) php-mysql-5.1.6-27.el5_5.3.i386 所以正确的卸载顺序是:
# rpm -e php-mysql-5.1.6-27.el5_5.3
# rpm -e php-pdo-5.1.6-27.el5_5.3
# rpm -e php-xml-5.1.6-27.el5_5.3
# rpm -e php-cli-5.1.6-27.el5_5.3
# rpm -e php-gd-5.1.6-27.el5_5.3
# rpm -e php-common-5.1.6-27.el5_5.3 再用# php -v 查看版本信息已经没有提示
2.接下来就是安装php5.6版本了
**centos 上用yum安装php版本太低了是5.3的,所以要更新下yum源,这点很重要**
配置yum源
追加CentOS 6.8的epel及remi源。
# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
以下是CentOS 7.0的源。
# yum install epel-release
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
使用yum list命令查看可安装的包(Packege)。
# yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
安装PHP5.6
yum源配置好了,下一步就安装PHP5.6(更新源后,也可以安装php7 的下面的56改成70)
# yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof
用PHP命令查看版本。
参考: http://skinglzw.blog.51cto.com/10729606/1889170
http://blog.csdn.net/simplty/article/details/38444151