默认的版本太低了,手动安装有一些麻烦,想采用Yum安装的可以使用下面的方案:
首先删除旧版本的PHP,
通过yum list installed | grep php可以查看所有已安装的php软件
使用yum remove php ……删除
通过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
参考资料
How to Upgrade PHP 5.3.x to PHP 5.4.x on CentOS
http://www.nginxtips.com/how-to-upgrade-php-5-3-x-to-php-5-4-x-on-centos/
Webtatic EL6的YUM源
https://webtatic.com/packages/php54/
http://*.com/questions/11361068/install-php-5-4-1-in-centos6-2