I've set up nginx and php-fpm under Arch Linux on a RasPi. nginx was set up in a chroot as described in the ArchWiki. Everything runs fine when php-fpm.conf and nginx.conf are set up to listen to and php-fpm.conf doesn't declare a path to the pid.

Now I want to change the setup to use a UNIX socket as is suggested across the web. So I added to php-fpm.conf the following.

pid = /srv/http/run/php-fpm/php-fpm.pid
chroot = /srv/http;
listen = /srv/http/run/php-fpm/php-fpm.sock

Also replaced fastcgi_pass in nginx.conf with

fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;

When I manually create the .sock file and restart both php-fpm and nginx, it works. But whenever I reboot, the php-fpm directory and .sock file are gone...

How can I preserve them across reboots? /etc/fstab includes

tmpfs           /srv/http/run   tmpfs   rw,noexec,relatime,size=1024k   0       0
tmpfs           /srv/http/tmp   tmpfs   rw,noexec,relatime,size=102400k 0       0

2 Answers 2


You can't. This would be the same thing as preserving a TCP connection over reboot. The socket is created by the process that listens on it (in your case php-fpm) and nginx connects to it. If you get problems because nginx can't open it, you most probably start your services in the wrong order (you'd have to start php-fpm before starting nginx, so that the socket exists when nginx starts).

  • Okay, that makes sense. Also shows I need to learn a lot more about networking :). I'll look into the starting order of processes in systemctl.
    – s.d
    Apr 7, 2014 at 20:21
  • Actually this doesn't work. Starting php-fpm.service before nginx.service simply results in nginx not starting at all, as php-fpm won't start because the sock file doesn't exist... I'll start a new question, as the issue seems to be to let php-fpm.service create the sock at startup.
    – s.d
    Apr 7, 2014 at 22:16

tmpfiles (part of systemd) will create and remove temporary/volatile directories and files. Typically these are placed in /run or /tmp, but it will work anywhere.

To have the directory /srv/http/run/php-fpm create on startup, create a config file in /etc/tmpfiles.d like this:

d /srv/http/run/php-fpm 0755 http http -

This will create the directory with the permissions 0755 for the http user and group (Arch's default php-fpm / web user)

The file can be called whatever you like but needs to end in .conf. Example (php-fpm.conf)

The socket itself is created by php-fpm when it starts, so be sure it is enabled in systemd:

systemctl enable php-fpm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.