AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 834616
Accepted
Merc
Merc
Asked: 2017-02-24 22:39:16 +0800 CST2017-02-24 22:39:16 +0800 CST 2017-02-24 22:39:16 +0800 CST

CentOs 7:如果 http 侦听特定的 IP 地址,它将不会在启动时启动

  • 772

我的 httpd.conf 中有这个:

Listen 216.XX.YY.ZZZZ:80

只是为了确保,我确保在启动时启用了 httpd:

systemctl httpd enable

当系统启动时,我有:

systemctl status httpd

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2017-02-23 22:21:03 PST; 8min ago
  Process: 719 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 719 (code=exited, status=1/FAILURE)

Feb 23 22:21:00 centosXXXXXX.aspadmin.net systemd[1]: Starting The Apache HTTP Server...
Feb 23 22:21:03 centosXXXXXX.aspadmin.net httpd[719]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address 216.XX.YY.XXX:80
Feb 23 22:21:03 centosXXXXXX.aspadmin.net httpd[719]: no listening sockets available, shutting down
Feb 23 22:21:03 centosXXXXXX.aspadmin.net httpd[719]: AH00015: Unable to open logs
Feb 23 22:21:03 centosXXXXXX.aspadmin.net systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Feb 23 22:21:03 centosXXXXXX.aspadmin.net systemd[1]: Failed to start The Apache HTTP Server.
Feb 23 22:21:03 centosXXXXXX.aspadmin.net systemd[1]: Unit httpd.service entered failed state.
Feb 23 22:21:03 centosXXXXXX.aspadmin.net systemd[1]: httpd.service failed.

然后我可以通过运行来启动它:

systemctl start httpd

一切正常:

systemctl status httpd


● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-02-23 22:31:53 PST; 3s ago
 Main PID: 2804 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
       ├─2804 /usr/sbin/httpd -DFOREGROUND
       ├─2805 /usr/sbin/httpd -DFOREGROUND
       ├─2806 /usr/sbin/httpd -DFOREGROUND
       ├─2808 /usr/sbin/httpd -DFOREGROUND
       ├─2824 /usr/sbin/httpd -DFOREGROUND
       └─2831 /usr/sbin/httpd -DFOREGROUND

Feb 23 22:31:53 centosXXXXXX.aspadmin.net systemd[1]: Starting The Apache HTTP Server...
Feb 23 22:31:53 centosXXXXXX.aspadmin.net httpd[2804]: AH00558: httpd:     Feb 23 22:31:53 centosXXXXXX.aspadmin.net systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

使用. 中的普通网络脚本将 IP 分配给 eth0 /etc/sysconfig/network-scripts/ifcfg-eth0。

检查/lib/systemd/system/httpd.service我有:

[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target

网上唯一类似的问题在这里:https ://unix.stackexchange.com/questions/207063/apache-httpd-failing-to-start-on-boot-centos-7但是,他们的建议:

systemctl enable NetworkManager-wait-online.service
Failed to execute operation: No such file or directory

似乎不起作用。

我完全迷路了。

centos httpd centos7 systemd rhel7
  • 1 1 个回答
  • 1211 Views

1 个回答

  • Voted
  1. Best Answer
    Merc
    2017-02-25T19:34:41+08:002017-02-25T19:34:41+08:00

    事实证明,您需要使用 NetworkManager 才能工作,因为您想等待 IP实际可用。CentOs 7 默认不安装 NetworkManager。

    所以:

    # yum install NetworkManager
    

    启用它:

    systemctl enable NetworkManager-wait-online
    

    然后:

    # systemctl edit httpd.service
    

    并添加:

    After=network.target NetworkManager-wait-online.service remote-fs.target nss-lookup.target
    

    此时,HTTPD 只会在 IP 分配给接口和 bingo 后才会启动,它才会真正启动。

    • 1

相关问题

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 使用 crontab 和 /etc/cron.hourly,daily,weekly 的区别

  • 持续监控许多服务器运行状况的简单方法?

  • Hudson 无法在 tomcat5 中启动

  • CentOS 的依赖挑战

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve