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

XAMPP Apache 啟動失敗「Busy... Port 80」完整排查與雙重解決方案

編輯:關於伺服器

XAMPP 控制面板顯示 Apache started [port 80] 但狀態非 Running,實際端口仍佔用於舊進程。核心衝突源:系統服務 (IIS/W3SVC)、其他 Web 伺服器、SSL 443 端口佔用。本文提供「釋放端口」與「變更端口」雙軌解決方案,並附錯誤日誌定位技巧。

現象確認

  • XAMPP 面板:busy... Apache started [port 80]
  • 瀏覽器 https://localhost 無法訪問
  • netstat -ano | findstr :80 顯示 PID 非 Apache

方案一:釋放 80 端口 (保持預設,推薦)

  1. 定佔用進程:
    netstat -ano | findstr :80
    # 輸出範例:TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 1236
    
  2. 識別進程名稱:
    tasklist | findstr 1236
    # 或任務管理器 → 詳情 → PID 欄排序
    
    常見佔用者:System (IIS/W3SVC)、httpd.exe (殘留 Apache)、nginx.exe、vmware-hostd.exe。
  3. 停用/禁用佔用服務:
    • IIS: 服務管理器停用 World Wide Web Publishing Service (W3SVC),設為「手動」或「禁用」。
    • 其他軟體: 修改其配置檔變更端口,或協載。
  4. 重啟 XAMPP Apache,面板應顯示 Running 綠燈。

方案二:變更 Apache 監聽端口 (共存方案)

  1. 編輯 xampp\apache\conf\httpd.conf:
    Listen 8081
    ServerName localhost:8081
    
  2. 編輯 xampp\apache\conf\extra\httpd-ssl.conf (若啟用 SSL):
    Listen 4433
    <VirtualHost _default_:4433>
    ServerName localhost:4433
    
  3. 若不需 SSL,編輯 httpd.conf 註釋:#Include conf/extra/httpd-ssl.conf
  4. XAMPP 面板重啟 Apache,訪問 https://localhost:8081 驗證。

現象說明: 面板仍可能顯示 Apache started [port 80],但實際監聽 8081,以瀏覽器實測為準。

進階:443 端口衝突處理 (IIS 佔用 SSL)

若啟用 SSL 仍報 443 佔用:

  1. 停用 IIS SSL:IIS 管理器 → 網站 → 繫結 → 移除 https 443。
  2. 或修改 Apache SSL 端口為 4433 (見上)。

終極診斷:錯誤日誌定位法

當上述方法均無效,查看 xampp\apache\logs\error.log 末尾:

# 常見關鍵錯誤
(OS 10048)Only one usage of each socket address is permitted.  : AH00072: make_sock: could not bind to address 0.0.0.0:80
# 確認為端口佔用,回歸方案一

最佳實踐建議

  1. 開發環境優先停用 IIS (Windows Features 關閉 IIS)。
  2. 生產/測試環境統一規劃端口:Apache 80/443、Nginx 8080/8443、Tomcat 8080/8443、Node 3000 等,避免衝突。
  3. 將 XAMPP 安裝路徑加入 PATH,習慣用 apache_start.bat 直接啟動,錯誤輸出直觀於控制台。

端口衝突是 XAMPP Apache 啟動失敗 90% 以上原因,掌握 netstat -ano + 任務管理器 + error.log 三板斧,分鐘級定位解決。

Copyright © Windows教程網 All Rights Reserved