centos6.5卸载原有的php5.3版本并安装php5.6

最新新弄了个服务器,centos6.5的系统,自带的php5.3版本太低了,所以在网上搜了一些资料,对php版本进行了更新,以下做个记录

1.卸载

php -v 查看当前php版本为5.3;

使用  #yum remove php 卸载php无法卸载干净,所以使用强制卸载

输入 #rpm -qa|grep php 出现类似下列信息:

php-cli-5.3.3-49.el6.x86_64
php-gd-5.3.3-49.el6.x86_64
php-odbc-5.3.3-49.el6.x86_64
php-xmlrpc-5.3.3-49.el6.x86_64
php-pdo-5.3.3-49.el6.x86_64
php-imap-5.3.3-49.el6.x86_64
php-pear-1.9.4-5.el6.noarch
php-mysql-5.3.3-49.el6.x86_64
php-mbstring-5.3.3-49.el6.x86_64
php-ldap-5.3.3-49.el6.x86_64
php-common-5.3.3-49.el6.x86_64
php-xml-5.3.3-49.el6.x86_64
php-bcmath-5.3.3-49.el6.x86_64
php-mcrypt-5.3.3-5.el6.x86_64

把上面的一个个的强制卸载掉就行了

不过因为有些存在依赖关系,所以卸载有先后顺序,自己看着卸载,出现错误了,换一个卸,都是卸载顺序的问题,

最后卸载php-common-5.3.3-49.el6.x86_64就行了。

卸载指令如 :rpm -e php-mysql-5.3.3-49.el6.x86_64

可以再次使用 #rpm -qa|grep php 命令查看是否已经卸载干净,然后使用 php -v则不会出现原来版本信息了。

2.安装php5.6

首先需要更新下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文件无法被解析,所以又查了下,使用yum又下载了以下安装包,

php56-php-gd.x86_64  
php56-php-cli.x86_64
php56-php-pdo.x86_64 
php56-php-pear.noarch  
php56-php-mysqlnd.x86_64
php56-php-mbstring.x86_64

例 yum install php56-php-gd.x86_64 

也可以用一次命令的安装  # yum --enablerepo=remi-php56 install php-gd php-mysql php-mbstring php-xml php-mcrypt php-pdo php-cli 

用空格隔开即可

重启apache服务  service httpd restart 

使用php -v查看版本已经更新到5.6

http://blog.csdn.net/qq_34432348/article/details/74626151

你可能感兴趣的:(linux)