Nginx – How to trace the cause of php-fpm terminating

centosnginxphp-fpmvps

I have VPS (4 core, 6GB) running centos, nginx and php-fpm, with very little traffic (I have never published the url).

Every few weeks (at different times), php-fpm terminates with only the following in php-fpm.log:

[10-Nov-2015 04:14:48] NOTICE: Terminating ...
[10-Nov-2015 04:14:48] NOTICE: exiting, bye-bye!

There are no other events at this time in the nginx error.log, or in php-fpm-error.log.

  • Where else can I look to find the cause of this termination?

  • Is there anything I can configure that will give me more information
    next time it happens?

  • Can I configure php-fpm to automatically restart?

Best Answer

You can use monit and its pid test in order to have php-fpm restarted when it crashes and optionally receive an email when this happens. Something like

set mail-format {
From: monit@host.name
Subject: $HOST $SERVICE $EVENT | $DATE
}

set alert your@email.address
check process php_fpm pidfile /var/run/php5-fpm.pid
 start program = "/etc/init.d/php5-fpm start"
 stop program = "/etc/init.d/php5-fpm stop"

The above was written with Debian7 in mind but you can adjust it to CentOS too.