今天重装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,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:80,再回车,就OK了~
如何解决Apache无法启动的问题,布布扣,bubuko.com