httpd/apachectl 服务无法在 RHEL 7 上启动

Posted

技术标签:

【中文标题】httpd/apachectl 服务无法在 RHEL 7 上启动【英文标题】:httpd/apachectl service fails to start on RHEL 7 【发布时间】:2018-09-16 23:46:08 【问题描述】:

我在从 RHEL 7 (Amazon ec2) 启动 Apache 服务器时遇到了一些问题。我更大的目标是使用 Anaconda 环境从 ec2 实例托管 Flask 应用程序,但现在我只关心如何正确启动 httpd 服务。

我发现here、here、here 等发布了许多类似的问题,但似乎都没有解决我遇到的确切问题。

我正在关注this tutorial 直到最后一个> 字符,但是命令

sudo apachectl restart

sudo service httpd restart

两者都会导致错误并指示我检查systemctl status httpd.service 以获取更多信息。该文件的输出如下:

httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2018-04-06 21:00:42 UTC; 4s ago
Docs: man:httpd(8)
      man:apachectl(8)
Process: 32166 ExecStop=/bin/kill -WINCH $MAINPID (code=exited, status=1/FAILURE)
Process: 32165 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=0/SUCCESS)
Main PID: 32165 (code=exited, status=0/SUCCESS)
[long ec2 ip address] systemd[1]: Starting The Apache HTTP Server...
[long ec2 ip address] httpd[32165]: httpd (pid 28220) already running
[long ec2 ip address] kill[32166]: kill: cannot find process ""
[long ec2 ip address] systemd[1]: httpd.service: control process exited, code=exited status=1
[long ec2 ip address] systemd[1]: Failed to start The Apache HTTP Server.
[long ec2 ip address] systemd[1]: Unit httpd.service entered failed state.
[long ec2 ip address] systemd[1]: httpd.service failed.

journalctl -xe 的输出返回相同。

关于我的系统的一些信息(不知道这些是否有帮助,但我认为最好包含它):

Apache Version: Apache/2.4.6 (Red Hat Enterprise Linux) configured

$ /usr/bin/python -V
    Python 2.7.5
$ sudo yum install mod_wsgi
    Package mod_wsgi-3.4-12.el7_0.x86_64 already installed and latest version
$ service httpd configtest
    Syntax OK
$ sudo chkconfig --levels 235 httpd on
    Note: Forwarding request to 'systemctl enable httpd.service' 

命令sudo netstat -lnp | grep :80 返回tcp 0 0 :::0 :::* LISTEN 28220/httpd

我现在注意到文件 /etc/init.d/httpd 不存在。

有人有提示吗?如果以前有人问过这个问题,请指导我。我已经搜遍了,到目前为止没有运气。

干杯。

【问题讨论】:

Stack Overflow 是一个编程和开发问题的网站。这个问题似乎离题了,因为它与编程或开发无关。请参阅帮助中心的What topics can I ask about here。也许Web Applications Stack Exchange、Webmaster Stack Exchange 或Unix & Linux Stack Exchange 会是一个更好的提问地点。 @jww 谢谢你的提示,我会试试的 【参考方案1】:

尝试杀死旧的pid。看起来有些东西仍在httpd 下运行。尝试执行ps -ef | grep httpd 以查看正在运行的内容并使用sudo kill -9 processid 将其杀死(例如sudo kill -9 13254)。

【讨论】:

就是这样,谢谢。此线程中给出的答案:unix.stackexchange.com/questions/436238/… 是的,它对我有用,为什么会出现这个错误我浏览了文档但没有得到任何合理的答案

以上是关于httpd/apachectl 服务无法在 RHEL 7 上启动的主要内容,如果未能解决你的问题,请参考以下文章

RHE Linux6.5 安装Oracle11.2.4记录

用ansible部署zabbix_agent

linux 挂载iso文件安装文件

虚拟化管理工具

Systemd初始化进程

MariaDB Galera 集群设置问题