大网数据广告活动
服务器运维问答

apache won't stop when using "service apache2 stop"

· 52CE 我爱测

I'm trying to work out an annoying issue. We have our server setup with nginx as the main front end, and then Apache2 as the backend for running our Perl scripts. I'm fighting through rewriting some of the Perl scripts (as they w…

问题原文

原帖链接 · Andrew Newby · CC BY-SA 3.0

I'm trying to work out an annoying issue. We have our server setup with nginx as the main front end, and then Apache2 as the backend for running our Perl scripts. I'm fighting through rewriting some of the Perl scripts (as they were used to running on a much older version of Perl), but I'm having a hell of a job with Apache. When I run:

service apache2 stop

It appears to run:

root@admin:/home/user/web/example.com/logs# service apache2 stop
root@admin:/home/user/web/example.com/logs#

But in fact, it still seems to be running! The command its triggering is:

/etc/init.d/apache2 stop

If I run this manually, I get:

root@admin:/home/user/web/example.com/logs# /etc/init.d/apache2 stop
[ ok ] Stopping apache2 (via systemctl): apache2.service.

..yet when I go to the browser and reload the page, it still loads!!!!! (which means Apache is running)

Anyone got any suggestions as to where I could look? Its driving me nuts! Please let me know if you need any more information.

I see a few processes running:

[] ps aux
root      5948  1.4  0.7 307664 91548 ?        Ss   13:32   0:00 /usr/sbin/apache2 -k start
www-data  5952  0.8  0.9 371080 111964 ?       S    13:32   0:00 /usr/sbin/apache2 -k start
www-data  5953  0.6  0.8 369416 110012 ?       S    13:32   0:00 /usr/sbin/apache2 -k start
www-data  5954  0.5  0.8 369416 110012 ?       S    13:32   0:00 /usr/sbin/apache2 -k start
www-data  5955  0.6  0.8 369416 110012 ?       S    13:32   0:00 /usr/sbin/apache2 -k start
www-data  5956  0.1  0.7 343800 90276 ?        S    13:32   0:00 /usr/sbin/apache2 -k start
www-data  5959  0.0  0.6 307688 79692 ?        S    13:32   0:00 /usr/sbin/apache2 -k start

UPDATE: As suggested, I tried using this to kill it off:

root@admin:~# pgrep apache2 | xargs kill -9
root@admin:~# pgrep apache2 | xargs kill -9
root@admin:~# pgrep apache2 | xargs kill -9
root@admin:~# pgrep apache2 | xargs kill -9
root@admin:~# pgrep apache2 | xargs kill -9
root@admin:~# pgrep apache2 | xargs kill -9

..but right after, I can see it again! (all with the same pid's)

root@admin:~# ps aux | grep apache
root      6080  0.4  0.7 307724 92052 ?        Ss   13:34   0:00 /usr/sbin/apache2 -k start
www-data  6084  0.2  0.8 369400 110024 ?       S    13:34   0:00 /usr/sbin/apache2 -k start
www-data  6085  0.2  0.8 369400 110024 ?       S    13:34   0:00 /usr/sbin/apache2 -k start
www-data  6086  0.1  0.8 369392 110240 ?       S    13:34   0:00 /usr/sbin/apache2 -k start
www-data  6087  0.1  0.8 369400 110024 ?       S    13:34   0:00 /usr/sbin/apache2 -k start
www-data  6088  0.1  0.8 369400 110244 ?       S    13:34   0:00 /usr/sbin/apache2 -k start
www-data  6400  0.3  0.8 369400 110024 ?       S    13:35   0:00 /usr/sbin/apache2 -k start
root      6520  0.0  0.0  14224   972 pts/0    S+   13:37   0:00 grep apache

UPDATE 2:

root@admin:~# killall -9 apache2
apache2: no process found
root@admin:~# ps aux | grep apache2
root      6977  1.2  0.8 315020 99236 ?        Ss   13:41   0:00 /usr/sbin/apache2 -k start
www-data  6981  0.4  0.9 376408 117364 ?       S    13:41   0:00 /usr/sbin/apache2 -k start
www-data  6982  0.4  0.9 376408 117364 ?       S    13:41   0:00 /usr/sbin/apache2 -k start
www-data  6983  0.4  0.9 376408 117364 ?       S    13:41   0:00 /usr/sbin/apache2 -k start
www-data  6984  0.5  0.9 376408 117364 ?       S    13:41   0:00 /usr/sbin/apache2 -k start
www-data  6985  0.0  0.7 315044 87100 ?        S    13:41   0:00 /usr/sbin/apache2 -k start
www-data  6988  0.0  0.7 315044 87100 ?        S    13:41   0:00 /usr/sbin/apache2 -k start
root      7048  0.0  0.0  14224   948 pts/0    S+   13:42   0:00 grep apache2

社区高分解答

原帖链接 · Bogdan Stoica · CC BY-SA 3.0

Maybe the process hanged for some reason. Did you try a kill -9 and the PID of the apache2 process id?

Alternativelly you could run for a couple of times this command:

pgrep apache2 | xargs kill -9

Then try to start it using /etc/init.d/apache2 start and see if it starts. After that you could take a look at your apache logs and see if you are able to find any useful information that you could use in order to investigate it further...

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-10-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。