今天啟動Apache時總是啟動失敗,提示如下:
15:45:28 [Apache] Attempting to start Apache service...
15:45:32 [Apache] Status change detected: running
15:45:33 [Apache] Status change detected: stopped
15:45:33 [Apache] Error: Apache shutdown unexpectedly.
15:45:33 [Apache] This may be due to a blocked port, missing dependencies,
15:45:33 [Apache] improper privileges, a crash, or a shutdown by another method.
15:45:33 [Apache] Press the Logs button to view error logs and check
15:45:33 [Apache] the Windows Event Viewer for more clues
15:45:33 [Apache] If you need more help, copy and post this
15:45:33 [Apache] entire log window on the forums
檢視log日志發現是80端口被占用,通常出現這種問題還可能是因為443端口被占用,這裡總結一下解決方法:
1.(1)443端口被占用
在/xampp/apache/conf/extra/httpd-ssl.conf ,把Listen 443 修改為 Listen 444(可自定義);
(2)80端口被占用
在/xampp/apache/conf/extra/httpd.conf ,把Listen 80 修改為Listen 88 (可自定義)
也可以在XAMPP面闆上直接進行修改
打開Config選項,打開第一項Appach(httpd.conf),将Listen 80修改為Listen 88
接着打開第二項Apache(httpd-ssl.conf),将Listen 443修改為Listen 444.這裡修改的端口并不固定,可以任意。
2.最直接的解決方式是直接把占用了端口号的程序kill掉,但是這裡并不推薦此種方法,因為下次啟動的時候可能還會遇到這種問題。