由于控制进程退出并显示错误代码,因此httpd.service的作业失败。有关详细信息,请参见“ systemctl状态httpd.service”和“ journalctl -xe”

Did*_*idi 5 apache centos7

我已经安装了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.
Run Code Online (Sandbox Code Playgroud)

Sta*_*low 11

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

apachectl configtest
Run Code Online (Sandbox Code Playgroud)


sys*_*end 8

从你的输出:

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

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

netstat -punta | grep LISTEN

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

做了一个nmap你的ip后,我可以看到

80/tcp    open     http
Run Code Online (Sandbox Code Playgroud)

所以我猜你已经解决了。


小智 7

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

SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket port 83 or 80
Run Code Online (Sandbox Code Playgroud)

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

nano /etc/selinux/config
Run Code Online (Sandbox Code Playgroud)

然后找到该行SELINUX=enforce并更改为SELINUX=disabled

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

setenforce 0

最后启动一个服务器

systemctl start httpd
Run Code Online (Sandbox Code Playgroud)


小智 6

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

/etc/httpd/conf/httpd.conf 
Run Code Online (Sandbox Code Playgroud)

因为我是mod_ssl使用 yum 命令安装的

yum -y install mod_ssl  
Run Code Online (Sandbox Code Playgroud)

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

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

grep  '443' /etc/httpd/conf.d/*
Run Code Online (Sandbox Code Playgroud)

下面是示例输出

/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
Run Code Online (Sandbox Code Playgroud)

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