PHP Apache shutdown unexpectedly啟動錯誤解釋及解決的方法


在學PHP的時候,偶然發現XAMPP窗體Apache的啟動出現錯誤,出現下面的錯誤提示:

9:52:41  [Apache] Attempting to start Apache app...

9:52:41  [Apache] Status change detected: running
9:52:42  [Apache] Status change detected: stopped
9:52:42  [Apache] Error: Apache shutdown unexpectedly.
9:52:42  [Apache] This may be due to a blocked port, missing dependencies, 
9:52:42  [Apache] improper privileges, a crash, or a shutdown by another method.
9:52:42  [Apache] Check the "/xampp/apache/logs/error.log" file

9:52:42  [Apache] and the Windows Event Viewer for more clues


這個問題比較常見, 一般是80、443port被占用

cmd 通過執行apache/bin/httpd.exe 打印例如以下log: 
通過執行cmd ,輸入命令行 netstat -a 查看全部的被占用的port;例如以下圖:

如圖可知, 443的port被占用了,導致Apache 無法正常啟動;

解決的方法例如以下:

(OS 10048)通常每一個套接字地址(協議/網絡地址/port)僅僅同意使用一次。 : make_sock: could not bind to address 0.0.0.0:443
或者后面是80port被占用

(OS 10048)通常每一個套接字地址(協議/網絡地址/port)僅僅同意使用一次。

: make_sock: could not bind to address 0.0.0.0:80 或[ : : ]:80

一、最快的處理方法就是改動port號:

1、443port被占用。apache無法監聽443port,該怎樣解決呢?

在/xampp/apache/conf/extra/httpd-ssl.conf

把Listen 443 改動為 444(可自己定義)


2、80port被占用,apache無法監聽80port。該怎樣解決呢?

在/xampp/apache/conf/extra/httpd.conf

把Listen 80 改動為 88 (可自己定義)

假設配置了vhosts的話請把httpd-vhosts.conf 中port改為88(同上port號)


二、最直接的方法是關閉占用80、443port的進程:
1. 通過cmd中netstat -ano 看看本機80、 443port被占用沒 ----- --這里 可能會被其它程序占用如iis、虛擬機等
2.通過cmd中打印tasklist,查找占用80、443port的進程名稱。


3.taskkill /pid port號 殺掉此進程名稱。XAMPP重新啟動apache就可以。

綜上所述第一種方法推薦使用,另外一種每次啟動都或多或少的再次遇到。




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM