monit无法启动apache

我正在运行Apache,并试图监视它与Monit。 监控似乎工作正常,但是当Apache停机时,Monit没有成功启动它。

Monit检测到它已closures,但启动命令失败。

下面是monitconfiguration

check process httpd with pidfile /var/run/httpd.pid start program = "/usr/bin/apachestart start" stop program = "/etc/init.d/httpd stop" if failed host 127.0.0.1 port 80 protocol http then restart if 5 restarts within 5 cycles then timeout 

这是指Apache的启动脚本,其中包括以下内容:

 # cat /usr/bin/apachestart ## start Apache with default settings ulimit -l 256; ulimit -s 56000; /usr/sbin/apachectl start; 

这个脚本设置了一些似乎是这个特定的Apache / PHP设置所需的参数。 从命令行以root身份运行时可以正常工作,但显然对于Monit来说,这是一个问题。

在debugging模式下运行monit(以“monit -Iv”开始),我得到以下内容

 monit: pidfile '/var/run/httpd.pid' does not exist 'httpd' process is not running ------------------------------------------------------------------------------- monit [0x40de4d] monit(LogError+0x9f) [0x40e59f] monit(Event_post+0x406) [0x40ba96] monit(check_process+0x98) [0x41d798] monit(validate+0x1b3) [0x41dbf3] monit [0x410547] monit(main+0x492) [0x410d72] /lib64/libc.so.6(__libc_start_main+0xf4) [0x30f961d994] monit [0x408e39] ------------------------------------------------------------------------------- Does not exist notification is sent to [email protected] Does not exist notification is sent to [email protected] 'httpd' trying to restart Monitoring disabled -- service httpd monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist 'httpd' start: /usr/bin/apachestart monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist monit: pidfile '/var/run/httpd.pid' does not exist 'httpd' failed to start ------------------------------------------------------------------------------- monit [0x40de4d] monit(LogError+0x9f) [0x40e59f] monit(Event_post+0x406) [0x40ba96] monit [0x409b7a] monit(control_service+0xcb) [0x409d8b] monit [0x40b3ae] monit(Event_post+0x445) [0x40bad5] monit(check_process+0x98) [0x41d798] monit(validate+0x1b3) [0x41dbf3] monit [0x410547] monit(main+0x492) [0x410d72] /lib64/libc.so.6(__libc_start_main+0xf4) [0x30f961d994] monit [0x408e39] ------------------------------------------------------------------------------- Execution failed notification is sent to ... 

任何想法为什么monit不能启动Apache?

/usr/sbin/apachectl start没有正确设置httpd的PID文件。

由于你的Monitconfiguration文件通过/var/run/httpd.pid跟踪进程,你应该使用/etc/init.d/httpd start作为你的启动程序。

如果你需要额外的参数,你可以把它们放在另一个configuration文件中。 这部分取决于您使用的是哪个版本的Linux。