I've created a directory to store socket files for PHP 5 FPM: sudo mkdir /var/run/php-fpm
. It is owned by root:root
as well as core PHP FPM process.
When PHP FPM is starting, it creates socket files for each pool inside of this directory and nginx uses them to communicate.
However, when I reboot my machine (sudo reboot
) this directory is gone after reboot and PHP FPM can't start, cause it can't create socket files inside of a missing directory.
What can be the problem? How do I debug it?
I'm using latest Ubuntu Server 14.04.
Best Answer
Current version of Ubuntu is using so-called up-start configs to run services. More info about this can be found here.
All up-start scripts are located in the
/etc/init
directory. Do not confuse it with old init scripts in/etc/init.d
directory.As @Rhim stated in his answer,
/var/run
is a temporary mounted filesystem, that is re-created after each reboot, so changes are not persisted in it. So in order to have a custom directory for socket files you will have to create it every time. The best place to add such functionality is an upstart config for PHP FPM located in:/etc/init/php5-fpm.conf
.Here's the modified version of this config:
pre-start
stanza was already used to check PHP FPM configuration file so I've converted it to a script section and added my own command for creating the direcotry for socket files before calling thecheckconf
.With this script it should work fine. In order to control state of the service use the
service
command like this:service php5-fpm start
,service php5-fpm restart
etc.I hope it will help someone. Cheers!