天天看點

如何解決Apache無法啟動的問題

今天重裝xampp後,一直無法啟動Apache,提示以下錯誤:

22:36:54 [Apache] Attempting to start Apache app...

22:36:54 [Apache] Status change detected: running

22:36:55 [Apache] Status change detected: stopped

22:36:55 [Apache] Error: Apache shutdown unexpectedly.

22:36:55 [Apache] This may be due to a blocked port, missing dependencies,

22:36:55 [Apache] improper privileges, a crash, or a shutdown by another method.

22:36:55 [Apache] Press the Logs button to view error logs and check

22:36:55 [Apache] the Windows Event Viewer for more clues

22:36:55 [Apache] If you need more help, copy and post this

22:36:55 [Apache] entire log window on the forums

大概意思是端口被占用,檢視xampp/apache/conf/httpd.conf檔案,裡面運用的是80端口,也是浏覽器預設的80端口。

首先,可以cmd,用netstat -ano來檢視端口的占用情況

1. netstat -ano|findstr "80"  檢視指定端口80的占用情況

C:\Users\acer>netstat -ano|findstr "80"

TCP        0.0.0.0:80                 0.0.0.0:0                  LISTENING         4

TCP        0.0.0.0:1026             0.0.0.0:0                   LISTENING        800

TCP        192.168.0.102:2113  183.136.138.140:80  TIME_WAIT        0

TCP        192.168.0.102:2114  183.136.138.140:80   ESTABLISHED   732

TCP        [::]:80                      [::]:0                        LISTENING         4

TCP        [::]:1026                   [::]:0                       LISTENING         800

UDP       [fe80::ce5:bd05:f942:83da%18]:1900 *:*                             1744

UDP       [fe80::d8c:1ba:16b4:2a29%17]:1900 *:*                              1744

UDP [fe80::7469:be65:7b61:a13b%14]:1900 *:*                                1744

依次表示 協定    本地位址                     外部位址               狀态                   PID

2. 用tasklist指令檢視PID對應的程序

C:\Users\acer>tasklist|findstr "732"

TaobaoProtect.exe          732 Console        1         7,956 K

依次表示  映像名稱                       PID 會話名              會話#       記憶體使用

3. 用taskkill指令可以關閉找到的程序,解除端口占用情況

C:\Users\acer>taskkill /f /t /im TaobaoProtect.exe

成功: 已終止 PID 732 (屬于 PID 1880 子程序)的程序。

但是有些情況下,我們有些程序是無法關閉的,或者對應程序較多的時候,關閉也很麻煩。退一步來講,我們可以選擇修改Apache對應的端口,豈不是兩全其美?

 我們繼續打開xampp/apache/conf/httpd.conf檔案,找到Listen80,将80改為81或者82and so on,保證該端口沒有被占用即可,可以用上面的方法進行檢驗。

我第一次是把所有的80都改為81的,後來發現,隻改listen後面這個也可以的~~具體可以去看看Apache的http.conf的詳細解釋,暫時覺得應該都改掉吧。

啊哈,接下來可以重新開機Apache了,運氣好的話,發現,還是端口被占用哦。

23:10:29 [Apache] Attempting to start Apache app...

23:10:29 [Apache] Status change detected: running

23:10:30 [Apache] Status change detected: stopped

23:10:30 [Apache] Error: Apache shutdown unexpectedly.

23:10:30 [Apache] This may be due to a blocked port, missing dependencies,

23:10:30 [Apache] improper privileges, a crash, or a shutdown by another method.

23:10:30 [Apache] Press the Logs button to view error logs and check

23:10:30 [Apache] the Windows Event Viewer for more clues

23:10:30 [Apache] If you need more help, copy and post this

23:10:30 [Apache] entire log window on the forums

Google了一下,發現,APACHE 還需要 443 端口,具體可以檢視xampp/apache/conf/extra/httpd-ssl.conf檔案,裡面有個listen443,檢查一下443端口的占用情況,又被占用了,一樣的,将443改為444.

如何找到上面兩個檔案,可以采取這樣的方式。如下圖,點選config,出現的前兩個,便是了~

如何解決Apache無法啟動的問題

重新開機Apache,OK,搞定,perfect!

23:20:40 [Apache] Attempting to start Apache app...

23:20:41 [Apache] Status change detected: running

點選admin,或者在浏覽器輸入localhost或者127.0.0.1,啊哦,

Not Found

HTTP Error 404. The requested resource is not found.

not found?因為浏覽器的預設端口号為80,而我們不是把端口改為81了嗎?此時可以在localhost後面加上端口号:localhost:81,再回車,就OK了~

轉載于:https://www.cnblogs.com/zdan68/p/3855636.html

繼續閱讀