由于工作需要,可能要进行Apache mariadb PHP等服务的卸载,闲话不多说,直接上方法。
Apache 卸载
我们的第一个例子就先拿 Apache 来开刀。不管你信不信现在我就要把它从Centos里卸载掉,不要问为什么,你懂的!执行下面一行代码
#rpm-qa|grephttpd
然后终端窗口就可显示如下两条信息
httpd-2.4.6-40.el7.centos.1.x86_64httpd-tools-2.4.6-40.el7.centos.1.x86_64
很棒,我们已经找到猎物了,下一步要做的就是有的放矢
#rpm-ehttpd-2.4.6-40.el7.centos.1.x86_64
error:Faileddependencies: httpd-mmn=20120211x8664isneededby(installed)PHP-5.4.16-36.1.el7_2.1.x86_64
稍微懂点英文的朋友估计已经知道这是什么回事了,大概意思就是说,PHP 依赖了 Apache 环境。
所以我们得先把这个幕后的“黑手”干掉。
在干掉它之前,我们肯定得了解下 PHP 的能力几何,配置了什么装备对吧,毕竟知己知彼,百战不殆!执行命令
#rpm-qa|grepPHP
终端会列出如下信息(这个会因人而异,就看你之前安装了多少扩展)
[root@niaoyun53098~]#rpm-qa|grepPHPPHP-cli-5.4.16-36.1.el7_2.1.x86_64 PHP-pear-1.9.4-21.el7.noarch PHP-mbstring-5.4.16-36.1.el7_2.1.x86_64 PHP-common-5.4.16-36.1.el7_2.1.x86_64 PHP-process-5.4.16-36.1.el7_2.1.x86_64 PHP-xml-5.4.16-36.1.el7_2.1.x86_64 PHP-gd-5.4.16-36.1.el7_2.1.x86_64 PHP-ldap-5.4.16-36.1.el7_2.1.x86_64 PHP-pdo-5.4.16-36.1.el7_2.1.x86_64 PHP-MysqL-5.4.16-36.1.el7_2.1.x86_64 PHP-bcmath-5.4.16-36.1.el7_2.1.x86_64 PHP-5.4.16-36.1.el7_2.1.x86_64 PHP-odbc-5.4.16-36.1.el7_2.1.x86_64 PHP-xmlrpc-5.4.16-36.1.el7_2.1.x86_64
扩展这么之,我们要删掉哪一个?答案是你可以全删了,也可以只删掉刚才报错的PHP-5.4.16-36.1.el7_2.1.x86_64,下面我就简单点只删掉PHP-5.4.16-36.1.el7_2.1.x86_64 这个绊脚石。
#rpm-ePHP-5.4.16-36.1.el7_2.1.x86_64
这个执行完之后,你再
查看下,在列出的信息中已经不见了PHP-5.4.16-36.1.el7_2.1.x86_64 的踪影了。接下来要做的就是 卸载 Apache 了。执行完后会有如下提示warning:/etc/httpd/conf/httpd.confsavedas/etc/httpd/conf/httpd.conf.rpmsave不用管它,现在执行下命令
里面只剩下httpd-tools-2.4.6-40.el7.centos.1.x86_64好了,到这里已经完成了 Apache 服务的卸载。
如果你觉得上面分两步执行很麻烦,那么你可以使用下面这一行命令来一石两鸟。
#yumerasehttpd这个命令行会自动的帮你卸载 httpd 服务,如果有其实服务(如 PHP )依赖于 Apache 的话,也会一同被卸载。
MariaDB 卸载
为了让你更详细的了解 yum erase 这个命令行,下面我用 yum erase *(*代表服务,如:MariaDB,Apache,FTP,PHP) 再来举个例子,由于我用的是centos 7,所以也装了一个MariaDB 数据库,所以就拿它来当这次的小白鼠吧。
下面是 yum erase mariadb 命令的 执行记录
[root@niaoyun53098~]#rpm-qa|grepmariadbmariadb-devel-5.5.47-1.el7_2.x86_64 mariadb-embedded-5.5.47-1.el7_2.x86_64 mariadb-bench-5.5.47-1.el7_2.x86_64 mariadb-server-5.5.47-1.el7_2.x86_64 mariadb-test-5.5.47-1.el7_2.x86_64 mariadb-libs-5.5.47-1.el7_2.x86_64 mariadb-embedded-devel-5.5.47-1.el7_2.x86_64mariadb-5.5.47-1.el7_2.x86_64 [root@niaoyun53098~]#rpm-emariadb-5.5.47-1.el7_2.x86_64 error:Faileddependencies: mariadb(x86-64)=1:5.5.47-1.el7_2isneededby(installed)mariadb-server-1:5.5.47-1.el7_2.x86_64 mariadb(x86-64)=1:5.5.47-1.el7_2isneededby(installed)mariadb-test-1:5.5.47-1.el7_2.x86_64 mariadb(x86-64)=1:5.5.47-1.el7_2isneededby(installed)mariadb-bench-1:5.5.47-1.el7_2.x86_64 [root@niaoyun53098~]#yumerasemariadb-5.5.47-1.el7_2.x86_64 Loadedplugins:fastestmirror ResolvingDependencies -->Runningtransactioncheck --->Packagemariadb.x86_641:5.5.47-1.el7_2willbeerased -->ProcessingDependency:mariadb(x86-64)=1:5.5.47-1.el7_2forpackage:1:mariadb-bench-5.5.47-1.el7_2.x86_64 -->ProcessingDependency:mariadb(x86-64)=1:5.5.47-1.el7_2forpackage:1:mariadb-test-5.5.47-1.el7_2.x86_64 -->ProcessingDependency:mariadb(x86-64)=1:5.5.47-1.el7_2forpackage:1:mariadb-server-5.5.47-1.el7_2.x86_64 -->Runningtransactioncheck --->Packagemariadb-bench.x86_641:5.5.47-1.el7_2willbeerased --->Packagemariadb-server.x86_641:5.5.47-1.el7_2willbeerased --->Packagemariadb-test.x86_641:5.5.47-1.el7_2willbeerased -->FinishedDependencyResolution DependenciesResolved =============================================================================================================================================================================================================== PackageArchVersionRepositorySize ===============================================================================================================================================================================================================Removing:mariadbx86_641:5.5.47-1.el7_2@updates49M Removingfordependencies:mariadb-benchx86_641:5.5.47-1.el7_2@updates2.6M mariadb-serverx86_641:5.5.47-1.el7_2@updates56M mariadb-testx86_641:5.5.47-1.el7_2@updates124M TransactionSummary =============================================================================================================================================================================================================== Remove1Package(+3Dependentpackages) Installedsize:231M Isthisok[y/N]:y Downloadingpackages:Runningtransactioncheck Runningtransactiontest Transactiontestsucceeded RunningtransactionWarning:RPMDBalteredoutsideofyum. Erasing:1:mariadb-bench-5.5.47-1.el7_2.x86_641/4Erasing:1:mariadb-test-5.5.47-1.el7_2.x86_642/4Erasing:1:mariadb-server-5.5.47-1.el7_2.x86_643/4warning:/var/log/mariadb/mariadb.logsavedas/var/log/mariadb/mariadb.log.rpmsave Erasing:1:mariadb-5.5.47-1.el7_2.x86_644/4Verifying:1:mariadb-bench-5.5.47-1.el7_2.x86_641/4Verifying:1:mariadb-test-5.5.47-1.el7_2.x86_642/4Verifying:1:mariadb-server-5.5.47-1.el7_2.x86_643/4Verifying:1:mariadb-5.5.47-1.el7_2.x86_644/4Removed:mariadb.x86_641:5.5.47-1.el7_2 DependencyRemoved:mariadb-bench.x86_641:5.5.47-1.el7_2mariadb-server.x86_641:5.5.47-1.el7_2mariadb-test.x86_641:5.5.47-1.el7_2 Complete! [root@niaoyun53098~]#rpm-qa|grepmariadbmariadb-devel-5.5.47-1.el7_2.x86_64 mariadb-embedded-5.5.47-1.el7_2.x86_64 mariadb-libs-5.5.47-1.el7_2.x86_64 mariadb-embedded-devel-5.5.47-1.el7_2.x86_64如果你看得够仔细的话,那会看到yum erase * 这个命令行是如何一步一步删掉目标服务的以及如何处理删除目标服务所依赖的服务。
搞定,收工~领盒饭啦!!
原文链接:/centos/379277.html