yum升级php到php7

https://www.51anidea.com/forum.php?mod=viewthread&tid=1255
(出处: Linux教程网)php

1、环境
CentOS 7
php版本:5.4.16mysql

2、升级方法
本文介绍升级到php7的方法。web

安装源:
#rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
#rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmsql

安装php7:
#yum install php70wphp7

若是出现如下报错:
Error: php70w-common conflicts with php-common-5.4.16-46.el7.x86_64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
看报错信息,故障缘由是安装的php7与旧版本的php-common-5.4.16-46.el7.x86_64冲突了。php-common-5.4.16-46.el7.x86_64 是旧版本的php包。因此应该卸载它。ide

卸载 php-common-5.4.16-46.el7.x86_64:
#rpm -e php-common-5.4.16-46.el7.x86_64ui

若是出现以下报错:
<div>
</div><div>error: Failed dependencies:
php-common(x86-64) = 5.4.16-46.el7 is needed by (installed) php-cli-5.4.16-46.el7.x86_64
php-common(x86-64) = 5.4.16-46.el7 is needed by (installed) php-pdo-5.4.16-46.el7.x86_64
php-common(x86-64) = 5.4.16-46.el7 is needed by (installed) php-5.4.16-46.el7.x86_64</div>idea

看报错信息,故障缘由是,要卸载的php-common-5.4.16-46.el7.x86_64 被 php-cli-5.4.16-46.el7.x86_6四、php-pdo-5.4.16-46.el7.x86_6四、php-5.4.16-46.el7.x86_64 这3个包依赖。这3个包都是旧版本的php包。因此就把这3个包一块儿卸载了:
#rpm -e php-common-5.4.16-46.el7.x86_64 php-cli-5.4.16-46.el7.x86_64 php-pdo-5.4.16-46.el7.x86_64 php-5.4.16-46.el7.x86_64教程

若是又出现以下报错:
error: Failed dependencies:
php-pdo(x86-64) = 5.4.16-46.el7 is needed by (installed) php-mysql-5.4.16-46.el7.x86_64ip

一样,要卸载的其中一个包被php-mysql-5.4.16-46.el7.x86_64 这个包依赖,php-mysql-5.4.16-46.el7.x86_64 是旧版本的php扩展包,因此也把它加入卸载的队伍:
#rpm -e php-common-5.4.16-46.el7.x86_64 php-cli-5.4.16-46.el7.x86_64 php-pdo-5.4.16-46.el7.x86_64 php-5.4.16-46.el7.x86_64 php-mysql-5.4.16-46.el7.x86_64

可能会出现如下警告信息:
warning: /etc/php.ini saved as /etc/php.ini.rpmsave

这个就不用管了。

再次执行命令:
#yum install php70w
终于成功安装上了。

再把php-mysql这个扩展包也更新了:
#yum install php70w-mysql

3、验证

执行如下命令检查php的版本:
#php -v
输出以下信息:PHP 7.0.33 (cli) (built: Dec 6 2018 22:30:44) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

证实php已经成功更新到php7。

相关文章
相关标签/搜索