因此,我刚刚使用 Yum 在新的 CentOS 7 服务器上安装了 Apache。我之前安装过 Apache 很多次,但从未见过这种情况:当我运行辅助现在,它总是显示
/usr/sbin/httpd -DFOREGROUND
谷歌告诉我,这意味着该进程将在前台运行并且不会脱离 shell,但我不明白这意味着什么——如果我关闭我的 shell,Apache 会死吗?
我只想获得正常的 Apache 行为,并让 httpd 像往常一样运行,在后台运行,我需要禁用 DFOREGROUND 吗?(顺便说一句,我不知道该怎么做)
答案1
这个-DFOREGROUND
选项确实意味着 Apache 不会分叉,但这并不意味着它附加到你的 shell 上!
服务由 systemd 在您运行时启动systemctl start httpd
(或使用旧方式service httpd start
)。Apache 附加到 systemd,systemd 将该进程作为其子进程之一进行管理。这样做是为了让 systemd 可以轻松判断 Apache 是否崩溃,而无需轮询 pid 文件或进行其他恶意黑客攻击。这也意味着systemd 能够自动地重新启动 Apache如果它确实崩溃了。
运行systemctl status httpd
以查看其状态。示例如下:
# systemctl status httpd
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: active (running) since Sat 2014-07-12 01:53:50 UTC; 1 weeks 3 days ago
Process: 21400 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
Main PID: 390 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─ 390 /usr/sbin/httpd -DFOREGROUND
├─15379 /usr/sbin/httpd -DFOREGROUND
├─15858 /usr/sbin/httpd -DFOREGROUND
├─16809 /usr/sbin/httpd -DFOREGROUND
├─16944 /usr/sbin/httpd -DFOREGROUND
├─17079 /usr/sbin/httpd -DFOREGROUND
├─17351 /usr/sbin/httpd -DFOREGROUND
├─17487 /usr/sbin/httpd -DFOREGROUND
├─17772 /usr/sbin/httpd -DFOREGROUND
├─17908 /usr/sbin/httpd -DFOREGROUND
└─18043 /usr/sbin/httpd -DFOREGROUND
Jul 12 01:53:50 hozen httpd[390]: AH02559: The SSLCertificateChai...d
Jul 12 01:53:50 hozen httpd[390]: AH00558: httpd: Could not relia...e
Jul 12 01:53:50 hozen systemd[1]: Started The Apache HTTP Server.
Jul 13 03:30:02 hozen systemd[1]: Reloading The Apache HTTP Server.
Jul 13 03:30:02 hozen httpd[9332]: AH02559: The SSLCertificateCha...d
Jul 13 03:30:02 hozen systemd[1]: Reloaded The Apache HTTP Server.
Jul 21 03:19:02 hozen systemd[1]: Reloading The Apache HTTP Server.
Jul 21 03:19:02 hozen httpd[21400]: AH02559: The SSLCertificateCh...d
Jul 21 03:19:02 hozen systemd[1]: Reloaded The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.