Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 移除 Apache 完整指南:RPM 與 APT 雙系統通用操作手冊

編輯:Linux 教學

RPM 系統 - RedHat/CentOS/Fedora

1. 查詢已安裝套件

rpm -qa | grep httpd

典型輸出:

httpd-2.2.3-11.el5_2.centos.4
httpd-manual-2.2.3-11.el5_2.centos.4

2. 依相依順序移除 (先移除依賴者)

rpm -e httpd-manual-2.2.3-11.el5_2.centos.4
rpm -e httpd

版本號可省略:rpm -e httpd-manual

3. 遇到相依衝突強制移除

rpm -e httpd --nodeps

警告:--nodeps 可能留下殘缺系統,僅作為最後手段。

APT 系統 - Debian/Ubuntu

1. 移除套件與相依

sudo apt-get remove --purge apache2
sudo apt-get autoremove --purge

2. 手動清理殘留配置與資料

sudo find /etc -name "*apache*" -exec rm -rf {} \;
sudo find /var -name "*apache*" -exec rm -rf {} \;
sudo find /usr -name "*apache*" -exec rm -rf {} \;

通用驗證步驟

# 確認程式二進制檔消失
which httpd || which apache2

# 確認服務腳本消失
ls /etc/init.d/ | grep -i apache

# 確認埠口釋放
netstat -tlnp | grep :80

RPM 參數速查表

參數功能
-i安裝
-v顯示詳細過程
-h顯示進度條
-e移除套件
--nodeps忽略相依關係
-qa查詢所有已安裝套件

補充:原始碼安裝移除

若為 tar.gz 手動編譯安裝,無套件管理器支援,需:

  1. 進入原始碼目錄執行 make uninstall (若 Makefile 支援)
  2. 或手動刪除安裝前缀目錄 (通常為 /usr/local/apache2)
Copyright © Windows教程網 All Rights Reserved