php-fpm doesn't create .sock file

  1. Make sure you have the following folder and that it's writable. /var/run/php-fpm

  2. then in your www.conf you put: listen = /var/run/php-fpm/php-fpm.sock

  3. then run: sudo service php-fpm restart

  4. then update your nginx.conf: fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
  5. and finally restart nginx: sudo service nginx restart

Edit: The real solution here is that the listen in www.conf and fastcgi_pass in nginx configuration have to match. Whether you use sockets or tcp is up to you.

The answer was to not use a .sock file at all.

in /etc/php-fpm.d/www.conf it has:

listen = 127.0.0.1:9000

So in my nginx config I put

fastcgi_pass 127.0.0.1:9000;

Instead of using something like

fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

If your php-fpm is controlled by systemd you have to check PrivateTmp option in your php-fpm service unit file (you can this file this way find /etc/systemd -name "php-fpm*" ! -type d)

If this option is set to true PrivateTmp=true, new file system namespace will be created for php-fpm master process and other process will be unable to manipulate files in this namespace by default (nginx, for example). You can read more details about systemd PrivateTmp option here: https://www.freedesktop.org/software/systemd/man/systemd.exec.html

Hope this helps!

Tags:

Php

Centos

Php 7