yum安装的php默认的版本太低了,手动安装有一些麻烦,想采用Yum安装的可以使用下面的方案:
首先删除旧版本的PHP,通过
yum list installed | grep php
可以查看所有已安装的php软件,使用
yum remove php
删除。
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-devel.x86_64 php-gd.x86_64 php-mbstring.x86_64 php-pdo.x86_64 php-xml.x86_64
通过yum list php*查看是否有自己需要安装的版本,如果没有就需要添加第三方yum源, 推荐安装webtatic、rpmforge,还有国内163的。
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 //rpmforge #32位: wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm rpm -ivh rpmforge-release-0.5.1-1.el5.rf.i386.rpm #64位: wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm rpm -ivh rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
安装完成后可以使用yum repolist查看已经安装的源,也可以通过ls /etc/yum.repos.d/查看。
然后再yum install php55w或yum install php54w或yum install php56w||yum install php70w……就可以安装新版本PHP了
1.首页安装Webtatic EL6 YUM源
rpm -Uvh http://repo.webtatic.com/yum/el6/latest.rpm
2.停止web服务器
service nginx stop
或者
service httpd stop
3.删除当前的 php 安装 php5.4
yum remove php*
yum install php54w
4.重启web服务器
service php-fpm restart
service nginx start
或者
service httpd restart
5.查看php版本
php -v
PHP 5.4.33 (cli) (built: Sep 19 2014 19:58:27)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
---------------------------------------------------------------
这里以centos5.6 安装 php5.6举例
yum list installed | grep php yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-devel.x86_64 php-gd.x86_64 php-mbstring.x86_64 php-pdo.x86_64 php-xml.x86_64 rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm service httpd stop service mysqld stop yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-devel.x86_64 php56w-xml.x86_64 service httpd start service mysqld start php -v