標籤:centos 7 卸載apache mariadb php等方法
由於工作需要,可能要進行Apache mariadb php等服務的卸載,閑話不多說,直接上方法。
Apache 卸載
我們的第一個例子就先拿 Apache 來開刀。不管你信不信現在我就要把它從Centos裡卸載掉,不要問為什麼,你懂的!執行下面一行代碼
# rpm -qa|grep httpd
然後終端視窗就可顯示如下兩條資訊
httpd-2.4.6-40.el7.centos.1.x86_64httpd-tools-2.4.6-40.el7.centos.1.x86_64
很棒,我們已經找到獵物了,下一步要做的就是有的放矢
# rpm -e httpd-2.4.6-40.el7.centos.1.x86_64
斷行符號後竟然提示如下錯誤
error: Failed dependencies:httpd-mmn = 20120211x8664 is needed by (installed) php-5.4.16-36.1.el7_2.1.x86_64
稍微懂點英文的朋友估計已經知道這是什麼回事了,大概意思就是說,php 依賴了 Apache 環境。
所以我們得先把這個幕後的“黑手”幹掉。
在幹掉它之前,我們肯定得瞭解下 php 的能力幾何,配置了什麼裝備對吧,畢竟知己知彼,百戰不殆!執行命令
# rpm -qa|grep php
終端會列出如下資訊(這個會因人而異,就看你之前安裝了多少擴充)
[[email protected] ~]# rpm -qa|grep phpphp-cli-5.4.16-36.1.el7_2.1.x86_64php-pear-1.9.4-21.el7.noarchphp-mbstring-5.4.16-36.1.el7_2.1.x86_64php-common-5.4.16-36.1.el7_2.1.x86_64php-process-5.4.16-36.1.el7_2.1.x86_64php-xml-5.4.16-36.1.el7_2.1.x86_64php-gd-5.4.16-36.1.el7_2.1.x86_64php-ldap-5.4.16-36.1.el7_2.1.x86_64php-pdo-5.4.16-36.1.el7_2.1.x86_64php-mysql-5.4.16-36.1.el7_2.1.x86_64php-bcmath-5.4.16-36.1.el7_2.1.x86_64php-5.4.16-36.1.el7_2.1.x86_64php-odbc-5.4.16-36.1.el7_2.1.x86_64php-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 -e php-5.4.16-36.1.el7_2.1.x86_64
這個執行完之後,你再
# rpm -qa|grep php
查看下,在列出的資訊中已經不見了 php-5.4.16-36.1.el7_2.1.x86_64 的蹤影了。接下來要做的就是 卸載 Apache 了。
# rpm -e httpd-2.4.6-40.el7.centos.1.x86_64
執行完後會有如下提示
warning: /etc/httpd/conf/httpd.conf saved as /etc/httpd/conf/httpd.conf.rpmsave
不用管它,現在執行下命令
# rpm -qa|grep httpd
裡面只剩下
httpd-tools-2.4.6-40.el7.centos.1.x86_64
好了,到這裡已經完成了 Apache 服務的卸載。
如果你覺得上面分兩步執行很麻煩,那麼你可以使用下面這一行命令來一石兩鳥。
# yum erase httpd
這個命令列會自動的幫你卸載 httpd 服務,如果有其實服務(如 php )依賴於 Apache 的話,也會一同被卸載。
MariaDB 卸載
為了讓你更詳細的瞭解 yum erase 這個命令列,下面我用 yum erase *(*代表格服務,如:MariaDB,Apache,FTP,php) 再來舉個例子,由於我用的是centos 7,所以也裝了一個MariaDB 資料庫,所以就拿它來當這次的小白鼠吧。
下面是 yum erase mariadb 命令的 執行記錄
[[email protected] ~]# rpm -qa|grep mariadbmariadb-devel-5.5.47-1.el7_2.x86_64mariadb-embedded-5.5.47-1.el7_2.x86_64mariadb-bench-5.5.47-1.el7_2.x86_64mariadb-server-5.5.47-1.el7_2.x86_64mariadb-test-5.5.47-1.el7_2.x86_64mariadb-libs-5.5.47-1.el7_2.x86_64mariadb-embedded-devel-5.5.47-1.el7_2.x86_64mariadb-5.5.47-1.el7_2.x86_64[[email protected] ~]# rpm -e mariadb-5.5.47-1.el7_2.x86_64error: Failed dependencies:mariadb(x86-64) = 1:5.5.47-1.el7_2 is needed by (installed) mariadb-server-1:5.5.47-1.el7_2.x86_64mariadb(x86-64) = 1:5.5.47-1.el7_2 is needed by (installed) mariadb-test-1:5.5.47-1.el7_2.x86_64mariadb(x86-64) = 1:5.5.47-1.el7_2 is needed by (installed) mariadb-bench-1:5.5.47-1.el7_2.x86_64[[email protected] ~]# yum erase mariadb-5.5.47-1.el7_2.x86_64Loaded plugins: fastestmirrorResolving Dependencies--> Running transaction check---> Package mariadb.x86_64 1:5.5.47-1.el7_2 will be erased--> Processing Dependency: mariadb(x86-64) = 1:5.5.47-1.el7_2 for package: 1:mariadb-bench-5.5.47-1.el7_2.x86_64--> Processing Dependency: mariadb(x86-64) = 1:5.5.47-1.el7_2 for package: 1:mariadb-test-5.5.47-1.el7_2.x86_64--> Processing Dependency: mariadb(x86-64) = 1:5.5.47-1.el7_2 for package: 1:mariadb-server-5.5.47-1.el7_2.x86_64--> Running transaction check---> Package mariadb-bench.x86_64 1:5.5.47-1.el7_2 will be erased---> Package mariadb-server.x86_64 1:5.5.47-1.el7_2 will be erased---> Package mariadb-test.x86_64 1:5.5.47-1.el7_2 will be erased--> Finished Dependency ResolutionDependencies Resolved===============================================================================================================================================================================================================Package Arch Version Repository Size===============================================================================================================================================================================================================Removing:mariadb x86_64 1:5.5.47-1.el7_2 @updates 49 MRemoving for dependencies:mariadb-bench x86_64 1:5.5.47-1.el7_2 @updates 2.6 Mmariadb-server x86_64 1:5.5.47-1.el7_2 @updates 56 Mmariadb-test x86_64 1:5.5.47-1.el7_2 @updates 124 MTransaction Summary===============================================================================================================================================================================================================Remove 1 Package (+3 Dependent packages)Installed size: 231 MIs this ok [y/N]: yDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transactionWarning: RPMDB altered outside of yum.Erasing : 1:mariadb-bench-5.5.47-1.el7_2.x86_64 1/4Erasing : 1:mariadb-test-5.5.47-1.el7_2.x86_64 2/4Erasing : 1:mariadb-server-5.5.47-1.el7_2.x86_64 3/4warning: /var/log/mariadb/mariadb.log saved as /var/log/mariadb/mariadb.log.rpmsaveErasing : 1:mariadb-5.5.47-1.el7_2.x86_64 4/4Verifying : 1:mariadb-bench-5.5.47-1.el7_2.x86_64 1/4Verifying : 1:mariadb-test-5.5.47-1.el7_2.x86_64 2/4Verifying : 1:mariadb-server-5.5.47-1.el7_2.x86_64 3/4Verifying : 1:mariadb-5.5.47-1.el7_2.x86_64 4/4Removed:mariadb.x86_64 1:5.5.47-1.el7_2Dependency Removed:mariadb-bench.x86_64 1:5.5.47-1.el7_2 mariadb-server.x86_64 1:5.5.47-1.el7_2 mariadb-test.x86_64 1:5.5.47-1.el7_2Complete![[email protected] ~]# rpm -qa|grep mariadbmariadb-devel-5.5.47-1.el7_2.x86_64mariadb-embedded-5.5.47-1.el7_2.x86_64mariadb-libs-5.5.47-1.el7_2.x86_64mariadb-embedded-devel-5.5.47-1.el7_2.x86_64
如果你看得夠仔細的話,那會看到 yum erase * 這個命令列是如何一步一步刪掉目標服務的以及如何處理刪除目標服務所依賴的服務。
搞定,收工~領便當啦!!
CentOS 7 卸載Apache mariadb php等方法