二维码

yum升级php到php7

1356 人阅读 | 时间:2019年10月22日 14:56

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

一、环境
CentOS 7
php版本:5.4.16

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

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

安装php7:
#yum install php70w

如果出现以下报错:
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包。所以应该卸载它。

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

如果出现如下报错:
<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>

看报错信息,故障原因是,要卸载的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 这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_64

同样,要卸载的其中一个包被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

三、验证

执行以下命令检查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。


©著作权归作者所有:来自ZhiKuGroup博客作者没文化的原创作品,如需转载,请注明出处,否则将追究法律责任 来源:ZhiKuGroup博客,欢迎分享。

评论专区
  • 昵 称必填
  • 邮 箱选填
  • 网 址选填
◎已有 1 人评论
  • 访客  发表于 3个月前
    1楼

    文章论点明确,论据充分,说服力强。http://www.jinpaibeer.cn/tags-6922.html

搜索
作者介绍
30天热门
×
×
本站会员尊享VIP特权,现在就加入我们吧!登录注册×
»
会员登录
新用户注册
×
会员注册
已有账号登录
×