我刚刚重新安装XAMPP,当我试图在XAMPP控制面板中启动我的Apache服务器时,我现在得到以下错误:
16:50:25 [Apache] Status change detected: running
16:50:26 [Apache] Status change detected: stopped
16:50:26 [Apache] Error: Apache shutdown unexpectedly.
16:50:26 [Apache] This may be due to a blocked port, missing dependencies,
16:50:26 [Apache] improper privileges, a crash, or a shutdown by another method.
16:50:26 [Apache] Press the Logs button to view error logs and check
16:50:26 [Apache] the Windows Event Viewer for more clues
16:50:26 [Apache] If you need more help, copy and post this
16:50:26 [Apache] entire log window on the forums
我怎么解决这个问题?
您可以做的一件事是通过发出命令停止端口80上的服务
net stop http
在cmd中。系统将询问您是否确定要停止这些服务。我发现我有一些服务我没有使用,并关闭了它们。
要查看还有谁正在使用端口80,请键入cmd
netstat -abno
我假设您希望在端口80上运行Apache。如果是这种情况,并且希望保留冲突的服务,则需要将它们关联到一个新的端口。
如果问题不是端口繁忙,您也可以尝试以下方法:在XAMPP配置面板中选择“显示调试信息”。当启动Apache时,会显示类似“正在执行”c:\xampp\ Apache \bin\httpd.exe”的内容。如果你运行它
c:\xampp\apache\bin\httpd.exe
在cmd中,你会得到更多的信息(我曾经有一些问题与我的httpd.conf文件)。
相关:如何释放我的端口80在本地主机Windows?Apache不能在xampp中运行
好吧,没有端口80,没有Skype的指责!我的问题确实很简单(也很愚蠢),
在我为DocumentRoot指令指定的路径之后,我有一个额外的反斜杠(\)(在Windows上),所以我做了这样的更改,问题就像鸭汤一样消失了。
我的index.php在路径“D:\ sites\dummy”和我的httpd.conf是这样的:
<VirtualHost 127.0.0.2:80>
ServerName dummy.local
DocumentRoot "D:\websites\dummy\" #mistake here
</VirtualHost>
<Directory "D:\websites\dummy\"> #mistake here
Require all granted
</Directory>
所以就像这样改变这两行:
#first mistake fix:
DocumentRoot "D:\websites\dummy"
#second (similar) mistake fix:
<Directory "D:\websites\dummy">
...现在一切都好了。为了防止将来发生这样的错误,总是复制任何你想要引用的文件夹的路径,而不是自己输入。
如果更改端口不能解决上述建议的问题,并且如果您可能玩弄了文件目录结构(例如,在安装后更改文件夹的名称,就像我所做的那样),那么您可以尝试这样做,
打开XAMPP控制面板,点击Apache的“配置”
选择Apache (httpd.conf)
在打开的编辑器中,按CTRL+H找到旧文件夹名的所有实例,并用新文件夹名替换它。
例如,在我的例子中,我已经将XAMPP的主安装文件夹名称从Xam更改为XAMPP
在编辑器中修改如下:
Define SRVROOT "G:/Xam/apache"
ServerRoot "G:/Xam/apache"
DocumentRoot "G:/Xam/htdocs"
<Directory "G:/Xam/htdocs">
To
Define SRVROOT "G:/Xampp/apache"
ServerRoot "G:/Xampp/apache"
DocumentRoot "G:/Xampps/htdocs"
<Directory "G:/Xampps/htdocs">
在编辑器中还有许多其他这样的实例,只需找到并替换它们中的每一个。
对Apache (httpd-ssl.conf)也执行同样的操作。