无法在 Windows Server 2008 R2 上启动 Apache

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4803282/
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-09-15 16:04:21  来源:igfitidea点击:

Can't start Apache on Windows Server 2008 R2

windowsapachewindows-server-2008-r2

提问by Tom

I got the following error when trying to start apache:

尝试启动 apache 时出现以下错误:

(OS 10013)An attempt was made to access a socket in a way forbidden by its access permissions. : make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down. Unable to open logs

(OS 10013) 尝试以访问权限禁止的方式访问套接字。: make_sock: 无法绑定到地址 0.0.0.0:80 没有可用的侦听套接字,正在关闭。无法打开日志

I could start it before. I guess after I enabled feature of windows '.NET Framework 3.5'. now I can't start it properly. I have checked the port:

我以前可以启动它。我想在我启用了 windows '.NET Framework 3.5' 的功能之后。现在我无法正确启动它。我检查了端口:

netstat -aon|findstr "80"
 TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4
 TCP    [::]:80                [::]:0                 LISTENING       4
tasklist|findstr "4"
System Idle Process              0 Services                   0         24 K
System                           4 Services                   0        304 K

How to resolve this?

如何解决这个问题?

回答by eel ghEEz

After searching for a solution online, I saw people blaming MS SQL reporting services, all MS SQL services, Windows Remote Management service etc. But one post had a helpful diagnostic command that allowed to to track the listening service to w3svc.

在网上搜索解决方案后,我看到人们指责 MS SQL 报告服务、所有 MS SQL 服务、Windows 远程管理服务等。但有一篇文章有​​一个有用的诊断命令,可以跟踪 w3svc 的侦听服务。

TMG is Unable to Listen on Port 80 (no IIS was not installed) by Ori Yosefi, MSFT, October 15, 2010

TMG 无法侦听端口 80(未安装 IIS)作者:Ori Yosefi,MSFT,2010 年 10 月 15 日

    e:\DIR>netsh http show servicestate

    Snapshot of HTTP service state (Server Session View):
    -----------------------------------------------------

    Server session ID: FF00000320000001
        [..]
        URL group ID: FE00000340000001
                [..]
                Registered URLs:
                    HTTP://*:80/

    Request queues:
        Request queue name: DefaultAppPool
            [..]
            Controller process ID: 2724
            Process IDs:
                5412

I could see the services running under the detected PID using the tasklist command.

我可以使用 tasklist 命令查看在检测到的 PID 下运行的服务。

    e:\DIR>tasklist /svc
    [..]
    svchost.exe                   2724 W3SVC, WAS
    [..]

I could inquire configuration details of these services.

我可以查询这些服务的配置细节。

    e:\DIR>sc qc w3svc
    [SC] QueryServiceConfig SUCCESS

    SERVICE_NAME: w3svc
            TYPE               : 20  WIN32_SHARE_PROCESS
            START_TYPE         : 2   AUTO_START
            ERROR_CONTROL      : 1   NORMAL
            BINARY_PATH_NAME   : C:\Windows\system32\svchost.exe -k iissvcs
            LOAD_ORDER_GROUP   :
            TAG                : 0
            DISPLAY_NAME       : World Wide Web Publishing Service
            DEPENDENCIES       : WAS
                               : HTTP
            SERVICE_START_NAME : LocalSystem


    e:\DIR>sc qc was
    [SC] QueryServiceConfig SUCCESS

    SERVICE_NAME: was
            TYPE               : 20  WIN32_SHARE_PROCESS
            START_TYPE         : 3   DEMAND_START
            ERROR_CONTROL      : 1   NORMAL
            BINARY_PATH_NAME   : C:\Windows\system32\svchost.exe -k iissvcs
            LOAD_ORDER_GROUP   :
            TAG                : 0
            DISPLAY_NAME       : Windows Process Activation Service
            DEPENDENCIES       : RPCSS
            SERVICE_START_NAME : LocalSystem

I could not stop them from command line running as a regular user.

我无法阻止他们以普通用户身份运行命令行。

    e:\DIR>net stop w3svc
    System error 5 has occurred.

    Access is denied.


    e:\DIR>net stop was
    The following services are dependent on the Windows Process Activation Service service.
    Stopping the Windows Process Activation Service service will also stop these services.

       World Wide Web Publishing Service
       Net.Tcp Listener Adapter
       Net.Pipe Listener Adapter

    Do you want to continue this operation? (Y/N) [N]: y
    System error 5 has occurred.

    Access is denied.

Then I stopped World Wide Web Publishing Service through the Services GUI, services.msc. I also changed the startup type for this service to Manual. No service listened to TCP port 80 after that.

然后我通过服务 GUI 停止了万维网发布服务,services.msc. 我还将此服务的启动类型更改为手动。之后没有服务侦听 TCP 端口 80。

    e:\DIR>netstat -ano
    [..no process listening on TCP port 80..]

回答by sarnold

Perhaps you've hit the TCP time-wait state? http://msdn.microsoft.com/en-us/library/ms819739.aspx

也许您已经达到 TCP 时间等待状态?http://msdn.microsoft.com/en-us/library/ms819739.aspx

"TIME-WAIT makes certain that enough time has passed to ensure that any TCP segments that might have been misrouted or delayed are not delivered unexpectedly to a new, unrelated application with the same connection settings. RFC 793: Transmission Control Protocol DARPA Internet Program Protocol Specification specifies the length of time that a socket pair should not be reused as two maximum segment lifetimes (MSL), or four minutes. This time period is the default setting for Windows Server 2003 TCP/IP."

“TIME-WAIT 确保已经过去了足够的时间,以确保任何可能被错误路由或延迟的 TCP 段不会意外地传送到具有相同连接设置的新的、不相关的应用程序。RFC 793:传输控制协议 DARPA 互联网程序协议规范指定了一个套接字对不应作为两个最大段生存期 (MSL) 或四分钟重复使用的时间长度。此时间段是 Windows Server 2003 TCP/IP 的默认设置。

Server applications often use the SO_REUSEADDRsocket-option so they can be quickly restarted, but perhaps your build of Apache doesn't?

服务器应用程序通常使用SO_REUSEADDR套接字选项,因此它们可以快速重新启动,但也许您的 Apache 构建没有?

You'll know if it 'just works' after four minutes. :)

四分钟后你就会知道它是否“有效”。:)