Monit configuration for php-fpm

Adam Jimenez picture Adam Jimenez · Oct 21, 2011 · Viewed 13.7k times · Source

I'm struggling to find a monit config for php-fpm that works.

This is what I've tried:

### Monitoring php-fpm: the parent process.
check process php-fpm with pidfile /var/run/php-fpm/php-fpm.pid
  group phpcgi # phpcgi group
  start program = "/etc/init.d/php-fpm start"
  stop program  = "/etc/init.d/php-fpm stop"
  ## Test the UNIX socket. Restart if down.
  if failed unixsocket /var/run/php-fpm.sock then restart
  ## If the restarts attempts fail then alert.
  if 3 restarts within 5 cycles then timeout

But it fails because there is no php-fpm.sock (Centos 6)

Answer

Thom Seddon picture Thom Seddon · Jun 19, 2012

For anyone else with this problem on Centos 6, the php-fpm socket is in /var/run/php-fpm/php-fpm.sock

Hence final config would be like so:

check process php-fpm with pidfile /var/run/php-fpm/php-fpm.pid
  group phpcgi #change accordingly
  start program = "/etc/init.d/php-fpm start"
  stop program  = "/etc/init.d/php-fpm stop"
  if failed unixsocket /var/run/php-fpm/php-fpm.sock then restart
  if 3 restarts within 5 cycles then timeout