6

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?

3
  • 1
    php-fpm processes have a lifetime which is set in either the global or pool config file. You can configure an automatic restart at the end of the time. php.net/manual/en/install.fpm.configuration.php There is lots of information on SO and you should be able to solve your problem.
    – Ian Lewis
    Nov 10, 2015 at 17:51
  • because php-fpm perhaps is setup with emergency restart. you can check epoLl setting related in php-fpm.conf configure file
    – user331649
    Jan 13, 2016 at 10:07
  • I have the exact same problem. Have you been able to solve it, how?
    – BastiaanWW
    Oct 24, 2016 at 17:53

3 Answers 3

4

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: [email protected]
Subject: $HOST $SERVICE $EVENT | $DATE
}

set alert [email protected]
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.

2
  • 1
    Thanks, adamao - can monit provide information about the cause of the termination?
    – Paul S
    Nov 10, 2015 at 11:33
  • Nope. It just monitors the pid file and checks whether the process number that is describes is running or not.
    – adamo
    Nov 10, 2015 at 12:55
4

Which PHP version do you use? Have you tried to upgrade to the latest? Did you install it from rpm/deb or did compile it?

Can you check if there is any cron running at that time?

This is very often caused by logrotate, trying to restart the service.

Anyway in order to prevent a service outage, you can setup monit to check if the service is running and restart it if not. It also supports email notifications, so you will know about it.

1
  • PHP 5.6.5 and Zend Engine v2.6.0 installed from an image at vpssim.com. It happens at a different irregular time, each time.
    – Paul S
    Nov 10, 2015 at 11:01
2

PHP processes are not particularly reliabile when left running indefinitely. You should configure php-fpm to restart the worker processes every now-and-then often. Try changing

;pm.max_requests = 500

into

pm.max_requests = 500

for a start. That might not fix everything as you may possibly have other configuration problems, but changing max_requests is a good start. My server has been running for months without any downtime.

From here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .