Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 即使在强制终止后,RHEL7上的httpd服务也会自动重新启动_Linux_Apache_Systemd_Rhel7_Systemctl - Fatal编程技术网

Linux 即使在强制终止后,RHEL7上的httpd服务也会自动重新启动

Linux 即使在强制终止后,RHEL7上的httpd服务也会自动重新启动,linux,apache,systemd,rhel7,systemctl,Linux,Apache,Systemd,Rhel7,Systemctl,每次我停止httpd服务时,它都会自动启动。下面是配置文件 [root@server ~]# cat /usr/lib/systemd/system/httpd.service [Unit] Description=The Apache HTTP Server After=network.target remote-fs.target nss-lookup.target Documentation=man:httpd(8) Documentation=man:apachectl(8) [Ser

每次我停止httpd服务时,它都会自动启动。下面是配置文件

[root@server ~]# cat /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true

[Install]
WantedBy=multi-user.target
当我停止服务“systemctl stop httpd”时,我会在audit.log中看到以下行

type=SERVICE_STOP msg=audit(1532445336.059:18928): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=httpd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
几秒钟之内,我立即在日志文件中看到下面的条目,说明服务启动命令已经执行

type=SERVICE_START msg=audit(1532445411.613:18931): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=httpd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
看起来systemd正在自动启动服务,但我在配置文件中没有看到“Restart=always”

[root@server ~]# cat /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true

[Install]
WantedBy=multi-user.target
我甚至试过下面的,没有帮助

[Service]
Restart=on-failure

查看完整配置的systemctl show httpd

其他一些东西可能正在启动httpd服务器,例如套接字激活或systemd计时器

如果您不想启动服务,您可以在停止服务后使用
systemctl-mask-httpd
,但请小心使用--它也不会在启动时启动
unmask
重新开始使用该服务