Debian

systemd 沒有註意到 apache 啟動

  • June 9, 2016

我的 debian-system 已經感染了 systemd-virus…

當我發出“service apache2 start”命令啟動 apache 時,它認為它失敗了,但 apache 執行得很好。所以“service apache2 stop”什麼都不做,因為系統認為apache沒有啟動。要停止 apache,我必鬚髮出“killall apache2”

# service apache2 start
Job for apache2.service failed. See 'systemctl status apache2.service' 
  and 'journalctl -xn' for details.


# systemctl status apache2.service 
â apache2.service - LSB: Apache2 web server
  Loaded: loaded (/etc/init.d/apache2)
  Active: failed (Result: exit-code) since Thu 2016-06-09 15:49:43 CEST; 32s ago
 Process: 7513 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

Jun 09 15:49:43  apache2[7513]: Starting web server: apache2 failed!
Jun 09 15:49:43  apache2[7513]: The apache2 instance did not start within 20 seconds. Please read the log files to discover problems ... (warning).
Jun 09 15:49:43  systemd[1]: apache2.service: control process exited, code=exited status=1
Jun 09 15:49:43  systemd[1]: Failed to start LSB: Apache2 web server.
Jun 09 15:49:43  systemd[1]: Unit apache2.service entered failed state.

系統是debian 8.5;通過多個版本升級。

為什麼“系統”認為它失敗了,當 apache 啟動就好了?

[Thu Jun 09 16:11:40.945575 2016] [mpm_prefork:notice] [pid 13426] AH00163: Apache/2.4.10 (Debian) mod_python/3.3.1 Python/2.7.9 OpenSSL/1.0.1t configured -- resuming normal operations
[Thu Jun 09 16:11:40.945846 2016] [core:notice] [pid 13426] AH00094: Command line: '/usr/sbin/apache2'

更新 /etc/init.d/apache2 在以下位置查找 pidfile

/var/run/apache2/apache2.pid

,但文件實際上位於

/var/run/apache2.pid

,即少一個子目錄。

pidfile 在一個意想不到的地方。編輯

/etc/apache2/envvars

導出 APACHE_PID_FILE=/var/run/apache2$SUFFIX.pid

使“服務 apache2 啟動/停止”工作

引用自:https://serverfault.com/questions/782978