【问题标题】:Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for detailshttpd.service 的作业失败,因为控制进程以错误代码退出。有关详细信息,请参阅“systemctl status httpd.service”和“journalctl -xe”
【发布时间】:2016-09-04 07:22:31
【问题描述】:

我安装了 Centos 7 的新副本。然后我重新启动了 Apache,但 Apache 无法启动。我在这个问题上停留了 3 天。连支持都想不通。

sudo service httpd start


Failed to start apache :
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.


httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2016-05-09 16:08:02 BST; 59s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 5710 (code=exited, status=1/FAILURE)

May 09 16:08:02 mike079.startdedicated.de systemd[1]: Starting The Apache HTTP Server...
May 09 16:08:02 mike079.startdedicated.de httpd[5710]: (98)Address already in use: AH00072: make_sock: could not bind to address 85.25.12.20:80
May 09 16:08:02 startdedicated.de httpd[5710]: no listening sockets available, shutting down
May 09 16:08:02 startdedicated.de httpd[5710]: AH00015: Unable to open logs
May 09 16:08:02 startdedicated.de systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
May 09 16:08:02.startdedicated.de kill[5712]: kill: cannot find process ""
May 09 16:08:02 .startdedicated.de systemd[1]: httpd.service: control process exited, code=exited status=1
May 09 16:08:02startdedicated.de systemd[1]: Failed to start The Apache HTTP Server.
May 09 16:08:02 startdedicated.de systemd[1]: Unit httpd.service entered failed state.
May 09 16:08:02 mike: httpd.service failed.

【问题讨论】:

  • 你是怎么解决这个问题的?

标签: apache centos centos7 httpd.conf


【解决方案1】:

由于 vhost.conf 中的一个简单拼写错误,我得到了同样的错误。 请记住确保配置文件中没有任何错误。

apachectl configtest

【讨论】:

    【解决方案2】:

    从你的输出:

    没有可用的监听套接字,正在关闭

    这基本上意味着,一个 apache 将要侦听的任何端口都已被另一个应用程序使用。

    netstat -punta | grep LISTEN

    将为您提供所有正在使用的端口的列表以及识别哪个进程所需的信息,以便您可以 kill stop 或做任何您想做的事情。

    在对你的 ip 进行nmap 之后,我可以看到

    80/tcp    open     http
    

    所以我猜你已经解决了。

    【讨论】:

    • 谢谢我解决了端口不匹配的问题。
    • After doing a nmap of your ip .. 之后我有点迷路了。你能告诉我在那之后我应该如何测试?
    • @John nmap ip 是最快的方法
    【解决方案3】:

    在我的情况下,我收到错误只是因为我将文件中的 Listen 80 更改为 listen 443

    /etc/httpd/conf/httpd.conf 
    

    因为我已经使用 yum 命令安装了mod_ssl

    yum -y install mod_ssl  
    

    mod_ssl 安装期间创建的文件ssl.conf 中有重复的listen 443 指令。

    如果你有重复的监听 80 或 443,你可以通过在 linux centos (My linux) 中运行以下命令来验证这一点

    grep  '443' /etc/httpd/conf.d/*
    

    下面是示例输出

    /etc/httpd/conf.d/ssl.conf:Listen 443 https
    /etc/httpd/conf.d/ssl.conf:<VirtualHost _default_:443>
    /etc/httpd/conf.d/ssl.conf:#ServerName www.example.com:443
    

    只需将 httd.conf 中的 listen 443 恢复为 listen 80 即可解决我的问题。

    【讨论】:

    • grep '443' /etc/httpd/conf.d/* 救了我的命。原来有 ssl.conf,我在 httpd.conf 上设置了 vrtual 主机
    • 拯救了这一天。有什么办法可以看到正确的错误信息? apachectl configtest 只验证语法。
    【解决方案4】:

    在命令行输入journalctl -xe,结果将是

    SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket port 83 or 80
    

    这意味着 SELinux 正在您的机器上运行,您需要禁用它。然后通过键入以下内容编辑配置文件

    nano /etc/selinux/config
    

    然后找到SELINUX=enforce这一行,改成SELINUX=disabled

    然后输入以下内容并运行命令启动httpd

    setenforce 0

    最后启动一个服务器

    systemctl start httpd
    

    【讨论】:

      【解决方案5】:

      允许 Apache 通过防火墙

      允许默认的 HTTP 和 HTTPS 端口,端口 80 和 443,通过 firewalld:

      sudo firewall-cmd --permanent --add-port=80/tcp
      sudo firewall-cmd --permanent --add-port=443/tcp
      

      并重新加载防火墙:

      sudo firewall-cmd --reload
      

      【讨论】:

        【解决方案6】:

        其他一些服务可能正在使用端口 80:尝试停止其他服务:HTTPD、SSL、NGINX、PHP,使用命令 sudo systemctl stop 然后使用命令 sudo systemctl启动 httpd

        【讨论】:

        • sudo systemctl stop HTTPD, sudo systemctl stop SSL, sudo systemctl stop NGINX sudo systemctl stop PHP
        【解决方案7】:
        <VirtualHost *:80>
            ServerName www.YOURDOMAIN.COM
            ServerAlias YOURDOMAIN.COM
            DocumentRoot /var/www/YOURDOMAIN.COM/public_html
            ErrorLog /var/www/YOURDOMAIN.COM/error.log
            CustomLog /var/www/YOURDOMAIN.COM/requests.log combined
        
            DocumentRoot /var/www/YOURDOMAIN.COM/public_html
            <Directory />
                Options FollowSymLinks
                AllowOverride None
            </Directory>
            <Directory /var/www/YOURDOMAIN.COM/public_html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
            </Directory>
        
        </VirtualHost>
        

        【讨论】:

        • 请详细说明您的解决方案。您的回答对任何人都没有帮助。
        【解决方案8】:

        错误可能来自任何地方、配置、库或二进制文件。控制过程中的错误是系统在无法启动/重新启动服务时抛出的一般错误。在我的情况下,链接到 .service 文件中的 exe 的库之一有问题。修复那个库解决了这个问题。

        【讨论】:

        • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
        猜你喜欢
        • 2015-07-30
        • 1970-01-01
        • 2023-03-20
        • 2018-03-30
        • 1970-01-01
        • 2020-09-17
        • 1970-01-01
        • 1970-01-01
        • 2017-07-08
        相关资源
        最近更新 更多