php Apache 未从 XAMPP 控制面板运行(错误:Apache 意外关闭。这可能是由于端口被阻止)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17946150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:42:13  来源:igfitidea点击:

Apache is not running from XAMPP Control Panel ( Error: Apache shutdown unexpectedly. This may be due to a blocked port)

phpapacheserverxamppport

提问by Ripon Al Wasim

I have installed XAMPP (xampp-win32-1.8.2-0-VC9-installer.exe) on Windows 7 successfully. But unfortunately, the following error was found during running Apache from XAMPP Control Panel:

我已经在 Windows 7 上成功安装了 XAMPP (xampp-win32-1.8.2-0-VC9-installer.exe)。但不幸的是,在从 XAMPP 控制面板运行 Apache 时发现了以下错误:

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

Error on running Apache at XAMPP Controm Panel

在 XAMPP 控制面板上运行 Apache 时出错

回答by TheHiggsBroson

There are many possible answers for this problem. The most common and most likely is that you're running another program which is blocking port 80 or 443. If you've installed Skype, then you've found your problem! Change apache's port settings to 81 and apache will work. There's a good tutorial on that To check this you can open up your command line by clicking the start menu, and typing 'cmd', and enter the command

这个问题有很多可能的答案。最常见和最有可能的情况是您正在运行另一个阻止端口 80 或 443 的程序。如果您已经安装了 Skype,那么您就发现了问题!将 apache 的端口设置更改为 81,apache 就可以工作了。有一个很好的教程要检查这一点,您可以通过单击开始菜单打开命令行,然后输入“cmd”,然后输入命令

    netstat -nab

this wil return a list of programs that will vaguely resemble this pattern

这将返回一个与此模式有点相似的程序列表

    [someprogram.exe]
    UDP     [fe80::numbers:numbers:numbers:numbers%numbers]:portnumber

You need to find a line (or lines) ending in :80 and terminate them in order to start apache. If there is no line ending in :80, there are more things you can do.

您需要找到以 :80 结尾的一行(或几行)并终止它们以启动 apache。如果没有以 :80 结尾的行,则您可以执行更多操作。

First, navigate to xampp's directory (default is c:\xampp) and double click apache_start.bat. This will open up a comand line and return more detailed errors about why apache can't run. Mostly, be looking for syntax errors that you could've created by editing your httpd.conf, or httpd-ssl.conf files. This is very easy to do if you've edited it and are a new user.

首先,导航到 xampp 的目录(默认为 c:\xampp)并双击 apache_start.bat。这将打开一个命令行并返回有关 apache 无法运行的更详细的错误信息。大多数情况下,通过编辑您的 httpd.conf 或 httpd-ssl.conf 文件来查找您可能创建的语法错误。如果您编辑过它并且是新用户,这很容易做到。

If still this fails, your last hope is to check the apache error log by clicking on the logs tab in apache's row in the xampp control panel and clicking error log.

如果仍然失败,您最后的希望是通过单击 xampp 控制面板中 apache 行中的日志选项卡并单击错误日志来检查 apache 错误日志。

If none of this works, don't give up! You got this!

如果这些都不起作用,请不要放弃!你得到了这个!

Edit:If you change the port of apache, you will also have to go into httpd.conf (located in xampp/apache/conf) and near line 184, replace

编辑:如果您更改 apache 的端口,您还必须进入 httpd.conf(位于 xampp/apache/conf)和第 184 行附近,替换

ServerName localhost:80

ServerName localhost:80

with

ServerName localhost:81

ServerName localhost:81

It is also possible to specify port 81 in the url of your localhost, i.e.

也可以在 localhost 的 url 中指定端口 81,即

localhost:81/my_project.php

本地主机:81/my_project.php

回答by Muhammad Ashikuzzaman

1.Go in xampp/apache/conf/httpd.confand open it.
In the httpd.conffile at line 176Replace

1.进去xampp/apache/conf/httpd.conf打开。
在替换httpd.conf文件中line 176

ServerName localhost:80
with
ServerName localhost:81
It will work.

ServerName localhost:80

ServerName localhost:81
它将工作。

Or 2.Even if the above procedure doesn't work. Then in the same file (httpd.conf) at line 45replace

或 2.即使上述程序不起作用。然后在同一个文件 ( httpd.conf) 的第 45 行替换

   #Listen 0.0.0.0:80
   #Listen [::]:80
   Listen 80 

with

  #Listen 0.0.0.0:81
  #Listen [::]:81
  Listen 81

回答by 101

XAMPP Control Panel under Windows does not always reflect what is actually going on, unless you start it by "Run as administrator".

Windows 下的 XAMPP 控制面板并不总是反映实际发生的情况,除非您通过“以管理员身份运行”启动它。

回答by Branyac

Have you executed "setup_xampp.bat" script? It's inside XAMPP folder and it must be executed every time you change XAMPP folder.

您是否执行过“setup_xampp.bat”脚本?它位于 XAMPP 文件夹内,每次更改 XAMPP 文件夹时都必须执行它。

回答by Sushant Kochar

Accompanying Timmay's answer, You need to do two changes-

伴随着 Timmay 的回答,你需要做两个改变——

Listen 80 --> Listen 81 (near line 58)

听 80 --> 听 81(58 行附近)

ServerName localhost:80 --> ServerName localhost:81 (near line 218)

ServerName localhost:80 --> ServerName localhost:81(218 行附近)

回答by Behnam Mohammadi

Go in xampp/apache/conf/httpd.conf and open it. Then just chang 2 lines

进入 xampp/apache/conf/httpd.conf 并打开它。然后只需更改 2 行

Listen 80
to
Listen 81

And

ServerName localhost:80
to
ServerName localhost:81

Then start using admin privileges.

然后开始使用管理员权限。

回答by Black Mamba

In my case the problem was that both port 80 and 443 were in use: Steps to use to fix it are :

在我的情况下,问题是端口 80 和 443 都在使用中:修复它的步骤是:

  1. Open xampp and click on config button
  2. Now click on ( Appache )httpd.conf (Open in notepad or other editor)
  3. Now click ctrl+ h.
  4. Find 80and replace with 8080
  5. Now save and now click on Appache(httpd-ssl.conf).
  6. Now find 443and replace with 4430.
  7. Now your xampp must be working fine as both these code are never in use by other programs on your system.
  1. 打开 xampp 并单击配置按钮
  2. 现在点击(Appache)httpd.conf(在记事本或其他编辑器中打开)
  3. 现在点击ctrl+ h
  4. 查找80并替换为8080
  5. 现在保存并单击 Appache(httpd-ssl.conf)。
  6. 现在找到443并替换为4430.
  7. 现在您的 xampp 必须正常工作,因为系统上的其他程序从未使用过这两个代码。

Now your localhost will be available as localhost:8080

现在您的本地主机将可用 localhost:8080

回答by Noor M

Check if you have Skype installed on your machine.

检查您的机器上是否安装了 Skype。

Login and go to Tools - Options - Advanced - Connection and uncheck the box which says use port 80

登录并转到工具 - 选项 - 高级 - 连接并取消选中使用端口 80 的框

--

——

Check if Apache service is already installed by firing up services.msc from run command prompt.

通过从运行命令提示符启动 services.msc 来检查 Apache 服务是否已安装。

How to delete a service from command prompt? sc delete “serviceName”

如何从命令提示符删除服务?sc 删除“服务名称”

Remember serviceName should be replaced by exact name of the Apache service as shown is services list.

请记住 serviceName 应替换为 Apache 服务的确切名称,如服务列表所示。

Check if IIS is running and taking up port 80. If so, disable it.

检查 IIS 是否正在运行并占用端口 80。如果是,请禁用它。

--

——

Check if AVP (Kaspersky) is running and taking up port 80. If so add httpd.exe as an exception to allowed programs.

检查 AVP (Kaspersky) 是否正在运行并占用端口 80。如果是,请将 httpd.exe 添加为允许程序的例外。

--

——

Hope it helps.

希望能帮助到你。

回答by Arpit B Parekh

I have installed VMWare Workstation. So, It was causing the error.

我已经安装了 VMWare 工作站。所以,它导致了错误。

Services.msc and stopped the 'Workstation' Services.

This has solved my problems.

这解决了我的问题。

Thanks

谢谢

回答by vanduc1102

If you are installed Skype, Please check this option.

如果您安装了 Skype,请勾选此选项。

enter image description here

在此处输入图片说明

Another case is Windows 10

另一个案例是 Windows 10

Check this:

检查这个:

  1. Go to Start, type in services.msc
  2. Scroll down in the Services window to find the World Wide Web Publishing Service.
  3. Right-click on it, and select Stop or Disable it if you just want to use XAMPP only.
  1. 转到开始,输入 services.msc
  2. 在“服务”窗口中向下滚动以查找万维网发布服务。
  3. 如果您只想使用 XAMPP,请右键单击它,然后选择停止或禁用它。

enter image description here

在此处输入图片说明