【问题标题】:Can't stop/restart Apache2 service无法停止/重新启动 Apache2 服务
【发布时间】:2016-04-13 21:35:52
【问题描述】:

试图停止 Apache2 服务,但得到 PID 错误:

#service apache2 stop

[FAIL] Stopping web server: apache2 failed!
[....] There are processes named 'apache2' running which do not match your pid file which are left untouched in the name of safety, Plea[warnview the situation by hand. ... (warning).

试图杀死那些进程:

#kill -9 $(ps aux | grep apache2 | awk '{print $2}')

但它们会再次重生:

#ps aux | grep apache2
root     19279  0.0  0.0   4080   348 ?        Ss   05:10   0:00 runsv apache2
root     19280  0.0  0.0   4316   648 ?        S    05:10   0:00 /bin/sh /usr/sbin/apache2ctl -D FOREGROUND
root     19282  0.0  0.0  91344  5424 ?        S    05:10   0:00 /usr/sbin/apache2 -D FOREGROUND
www-data 19284  0.0  0.0 380500  2812 ?        Sl   05:10   0:00 /usr/sbin/apache2 -D FOREGROUND
www-data 19285  0.0  0.0 380500  2812 ?        Sl   05:10   0:00 /usr/sbin/apache2 -D FOREGROUND

虽然进程正在运行,但我无法连接到端口 80 上的服务器。/var/log/apache2/error.log.1 在我执行 kill -9 时没有新消息。 在我尝试重新启动之前,一切都运行良好。 在 Debian 上运行:Linux adara 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux

更新: 也试过apache2ctl:

#/usr/sbin/apache2ctl -k stop
AH00526: Syntax error on line 76 of /etc/apache2/apache2.conf:
PidFile takes one argument, A file for logging the server process ID
Action '-k stop' failed.
The Apache error log may have more information.

但是 /var/run/apache2 中没有 pid 文件

我是 linux 新手,看起来它必须对启动脚本做一些事情,但无法弄清楚到底是什么。

【问题讨论】:

    标签: linux debian apache2 init.d


    【解决方案1】:

    下面是查找80端口上运行的进程的命令

    lsof -i tcp:80

    使用 PID 杀死进程。重新启动系统一次以检查它们是否有任何启动脚本正在执行并使用端口 80,这会阻止您启动服务。

    你可以检查启动脚本

    /etc/init.d/ 或 /etc/rc.local 或 crontab -e

    【讨论】:

    • 这台服务器上还有其他服务,很遗憾,不能那么容易地重启它,但是如果我没有找到其他解决方案,我肯定会稍后再做。 lsof -i tcp:80 不返回任何内容
    【解决方案2】:

    您可以尝试使用 Apache 官方文档进行停止/重启操作。 link

    【讨论】:

    • kill 不起作用(进程重新生成),apache2ctl -k stop 需要 pid 文件,但它丢失了
    猜你喜欢
    • 1970-01-01
    • 2014-05-14
    • 2019-08-20
    • 1970-01-01
    • 2014-08-14
    • 1970-01-01
    • 1970-01-01
    • 2019-04-25
    • 1970-01-01
    相关资源
    最近更新 更多