相信很多人跟我一样,一开始是通过普通的yum remove php
来卸载PHP的。
但是执行完了之后,却发现还是能通过php -v
来获取PHP的版本信息,说明并没卸载干净。
所以必须得强制删除。
首先通过以下命令,查看有关PHP的全部软件包:
# rpm -qa|grep php
基本都是下面这些信息,只不过版本号有所不同:
# php-pdo-5.1.6-27.el5_5.3
# php-mysql-5.1.6-27.el5_5.3
# php-xml-5.1.6-27.el5_5.3
# php-cli-5.1.6-27.el5_5.3
# php-common-5.1.6-27.el5_5.3
# php-gd-5.1.6-27.el5_5.3
接下来就简单,直接使用rpm
命令来卸载,比如php-pdo-5.1.6-27.el5_5.3包,可以用这样的命令:
# rpm -e php-pdo
注意到没,后面并没有跟-5.1.6-27.el5_5.3,当然你想带上也行,效果是一样的。
像php-pdo
,php-common
这两个软件包,因为是其他包的依赖,卸载的时候会报下面这样的错误:
error: Failed dependencies:
php-pdo is needed by (installed) php-mysql-5.1.6-27.el5_5.3.i386
这时候不要慌,先卸载其他的软件包即可……
不过凡事都有意外,像我这样的Mr.Bug就有一次碰到了:
# rpm -e php-common
error: Failed dependencies:
php-common(x86-64) = 7.2.30-1.el7.remi is needed by (installed) php-json-7.2.30-1.el7.remi.x86_64
# rpm -e php-json
error: Failed dependencies:
php-json(x86-64) = 7.2.30-1.el7.remi is needed by (installed) php-common-7.2.30-1.el7.remi.x86_64
看到没,两个居然互为依赖。这缠缠绵绵的,单身狗的狗粮又多了一份。
解决方法很简单,remove
即可:
# yum remove php-common.x86_64
终于找到个能用的