代码改变世界

XAMPP错误: Apache shutdown unexpectedly解决办法 & 更改Apache端口号后如何打开localhost的解决办法 by yojiaku

2016-07-19 15:09  yojiaku  阅读(2253)  评论(0编辑  收藏  举报

---恢复内容开始---

今天,在启动XAMPP中Apache时遇到了这样的问题:

14:42:24  [Apache]  Error: Apache shutdown unexpectedly.
14:42:24  [Apache]  This may be due to a blocked port, missing dependencies,
14:42:24  [Apache]  improper privileges, a crash, or a shutdown by another method.
14:42:24  [Apache]  Press the Logs button to view error logs and check
14:42:24  [Apache]  the Windows Event Viewer for more clues
14:42:24  [Apache]  If you need more help, copy and post this
14:42:24  [Apache]  entire log window on the forums

出现这个错误的原因是:端口被占用

我们只需要修改Port(s)即可:

  1. 首先打开XAMPP Control Panel,找到Apache的Config文件:

    click The Config button, and select the Apache (httpd.conf).

    Inside the httpd.conf file, find this line:Listen 80 and this line:ServerName localhost:80,then change the number "80" to the any number you like,for example:"8080". Remember to save this file.

  2. Then select the Apache (httpd-ssl.conf). Inside this file, we should find three lines: 
    • Listen 443
    • <VirtualHost _default_:443>
    • ServerName www.example.com:443    then we can change the number "443" to any number we like, for example "4433". Last we should save this file.

  3. Restart the Apache service.

We can see this when we restart the Apache service:

and this:

15:01:32  [Apache]  Problem detected!
15:01:32  [Apache]  Port 80 in use by ""C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe" -k runservice" with PID 2820!
15:01:32  [Apache]  Apache WILL NOT start without the configured ports free!
15:01:32  [Apache]  You need to uninstall/disable/reconfigure the blocking application
15:01:32  [Apache]  or reconfigure Apache and the Control Panel to listen on a different port
15:01:32  [Apache]  Attempting to start Apache app...
15:01:32  [Apache]  Status change detected: running

It means we solve this problem.

Then we move to another problem: when we open the localhost, we see this:

To solve this problem, we should change "localhost" to "localhost:8080" ("8080" is your number which you have changed)

Just like this:

 

 

 

 

 

---恢复内容结束---