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。

相關文章
相關標籤/搜索