Why do my sockets keep disappearing?


I’m working on getting my froxlor instance setup with PHP5-FPM and Nginx and was encountering an issue whereupon reboot the PHP functionality would be broken. Looking in syslog would give me about 30 lines of PHP5-FPM failing to start and then giving up. Looking in /var/log/php5-fpm.log would tell me nothing useful other then the configtest passed.

I eventually found a helpful message in the /var/log/upstart/php5-fpm.log file:

[14-May-2015 09:21:54] ERROR: unable to bind listening socket for 
address '/var/run/nginx/username-domain.com-php-fpm.socket': No 
such file or directory (2)

True enough the /var/run/nginx folder did not exist. I could not figure out where it was going.

After hair pulling research I found that the /var/run mount point is run as tmpfs and so is deleted on reboot. In order to fix this I had to ensure the directory was recreated before PHP5-FPM started. It turns out this if fairly easy with upstart. I added this stanza:

pre-start
    ... other stuff ...
    [ -d /var/run/nginx ] || mkdir -p /var/run/nginx
end script

to the /etc/init/nginx.conf file to have the folder created on boot.

Problem solved.

Comments