15

I have an AWS server running on Amazon Linux.

I used this guide to install php7 (bottom of the page): https://forums.aws.amazon.com/thread.jspa?messageID=695576

I would like to use nginx instead of Apache, so I've also installed the php70w-fpm and nginx packages. However, when I service start php-fpm, it does not create a php-fpm.sock file anywhere on my server. I have checked in /var/run and have also ran find / -name "*.sock" which only returns /var/run/rpcbind.sock.

Kezaia
  • 419
  • 1
  • 3
  • 10

8 Answers8

11
  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
10

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;
Kezaia
  • 419
  • 1
  • 3
  • 10
  • 51
    This is not really an answer, just an alternative solution. The question at hand is specifically regarding socket files, not TCP/IP – R Down Jul 18 '16 at 21:40
  • PHP FPM is usually easier to set up on TCP/IP but therefore slower. – nito Jan 07 '17 at 05:29
  • @nito This is true however sockets can only handle a very small amount of traffic. – Kezaia Jan 08 '17 at 17:15
  • works for php7 + centos7 + nginx^^ no .sock file gets created on `service start` (permissions? not sure), either way this one works^ – treyBake Nov 16 '17 at 10:06
  • This answer helped me a lot: https://stackoverflow.com/a/15424808/104380 – vsync Apr 29 '18 at 19:15
5

I had the same problem - no socket created - and the same solution that Phil had.

I had just copy-pasted a pool-file, and only changed the socket-name in the listen-section. No socket.

This was because the pool name was already in use. When you already have pool with the same name, then there is not created a new socket.

So it is important to have a unique pool name for each socket.

So when copy/paste a pool configuration: Change both pool-name and socket-name!

  • This had been driving me nuts for hours. I'd copied a previous config file and forgot to change the [pool-name] - thank you very much! – Lewis Aug 18 '23 at 21:45
3

In my case, I missed in /etc/php/7.0/fpm/pool.d/wordpress.conf the correct section

[wordpress]
listen = /var/run/php7-fpm-wordpress.sock

The *.sock file is not created from filename but from section name.

Powerriegel
  • 595
  • 5
  • 16
  • 1
    Hallelujah! :D I also just forgot to change the "pool name" (did you mean this by "section") after copy and pasting from another config file. – FullStack Alex May 13 '19 at 12:39
3

I had the error, because I copy-pasted a pool.d/xx.conf and the new one had the same pool name [whatever], so the second was not loaded. No error, no socket.

Hope that helps someone :)

Phil
  • 3,282
  • 1
  • 20
  • 16
2

I know its too late, but may be this can help. You can create a new lock file from the scratch using Python.

python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/run/php/php-fpm.sock')"
2

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!

Kirzilla
  • 16,368
  • 26
  • 84
  • 129
1

In my case when changing PHP version example to PHP7.4 for a specific website in Ispconfig 3.2.2 the webxx.conf file should have been created in /etc/php/7.4/fpm/pool.d/ but instead, it was created at root /.

So for now I just mv the webxx.conf file to /etc/php/7.4/fpm/pool.d/ and restart PHP7.4-fpm sudo systemctl restart php7.4-fpm and it works correctly.

Sotmir Laci
  • 84
  • 1
  • 6