httpd.service 作业失败,因为控制进程退出并出现错误代码。有关详细信息,请参阅“systemctl status httpd.service”和“journalctl -xe”

问题描述 投票:0回答:12

我已经安装了新的 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
12个回答
30
投票

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

apachectl configtest

10
投票

从你的输出:

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

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

netstat -punta | grep LISTEN

将为您提供正在使用的所有端口的列表以及识别哪个进程所需的信息,以便您可以

kill
stop
或用它做任何您想做的事情。

对你的 ip 进行

nmap
操作后,我可以看到

80/tcp    open     http

所以我想你已经解决了。


10
投票

在我的例子中,我收到错误只是因为我将文件中的 Listen 80 更改为 Listen 443

/etc/httpd/conf/httpd.conf 

自从我使用 yum 命令安装了

mod_ssl

yum -y install mod_ssl  

ssl.conf
安装过程中创建的文件
mod_ssl
中存在重复的监听 443 指令。

如果您有重复的listen 80或443,您可以通过在linux centos(我的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 中的监听 443 恢复为监听 80 就可以解决我的问题。


7
投票

在命令行输入

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

4
投票

允许 Apache 通过防火墙

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

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

并重新加载防火墙:

sudo firewall-cmd --reload

2
投票

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


1
投票

对我来说,问题如下:

[Sat Sep 10 00:43:20.999998 2022] [auth_digest:error] [pid 123456] (2)No such file or directory: AH01762: Failed to create shared memory segment on file /run/httpd/authdigest_shm.128124
[Sat Sep 10 00:43:20.999999 2022] [auth_digest:error] [pid 123456] (2)No such file or directory: AH01760: failed to initialize shm - all nonce-count checking and one-time noncesdisabled

我刚刚跟踪错误日志以获取上面的这两行:

*ADMINSHELL* :/var/opt/custom_path/logs/httpd # tail error_log

所以问题是缺少这个文件夹:/run/httpd/

解决方案:

mkdir /run/httpd
chown root:httpd /run/httpd
chmod 0710 /run/httpd

完成后。您将能够重新启动服务:

systemctl restart httpd.service

双重检查:

systemctl status httpd.service

0
投票

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


0
投票

尝试这个cmd来了解文件配置中缺少的配置或错误 $ apachectl 配置测试


0
投票

我遇到了几乎相同的错误,并且我在

vhost.conf
文件上发现了错误,该文件位于
/etc/httpd/conf.d/vhost.conf

如果您正在配置虚拟主机,我建议您查看以下文件并查找是否有任何错误。

/etc/httpd/conf.d/vhost.conf


0
投票

对我来说,添加 dummy SSL

后也会发生同样的错误

/etc/httpd/conf.d/ssl.conf
文件中创建了一行,

SLCertificateFile /etc/pki/tls/certs/localhost.crt

我将其从 SLCertificateFile 更改为 SSLCertificateFile

SSLCertificateFile /etc/pki/tls/certs/localhost.crt

Apache 重新启动后,它开始正常工作。


-2
投票
<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>
© www.soinside.com 2019 - 2024. All rights reserved.