Nginx + php5-fpm graceful restart : reload on Ubuntu 14.04 LTS

nginxphp-fpmubuntu-14.04

I tried to find a way to gracvelly restart my server.

I tried sudo service php5-fpm reload && sudo service nginx reload

But this is not working as reloading php5-fpm on Ubuntu 14.04 is not working properly (The php5-fpm instance is showed as unknown)

After executing the previously command I got

sudo service php5-fpm status
> php5-fpm stop/waiting
sudo service php5-fpm restart
> stop: Unknown instance: 
> php5-fpm start/running, process 26042
sudo service php5-fpm restart
> stop: Unknown instance: 
> php5-fpm start/running, process 26141

The only way I found to restart php5-fpm after that is to run:

sudo killall php5-fpm
sudo service php5-fpm start
> php5-fpm start/running, process 26160

Thank You,

Best Answer

this one was killing me and all my coworkers too :) Here's the solution: Edit the file:

/etc/init/php5-fpm.conf

and uncomment the line containing (it's line 13 on my box):

reload signal USR2

Then kill all the php-fpms:

find their process ids:

ps aux | grep php-fpm

kill them:

sudo kill [proc-id]

And voila your "sudo service php5-fpm restart" is working again