6

I setup a system similar to the tutorial here.

I'm having issues with nginx connecting to the php5-fpm socket, but from what I can tell the permissions on the socket are correct... can you give me a hand?

2011/04/14 15:31:24 [crit] 13147#0: *1 connect() to unix:/var/run/php5-fpm.socket failed (2: No such file or directory) while connecting to upstream, client: 74.129.***.***, server: app.mydomain.com, request: "GET /phpinfo.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.socket:", host: "app.mydomain.com"

root@app0:/# ls -l /var/run/php5-fpm.socket
srw-rw-rw- 1 www-data www-data 0 Apr 14 15:51 /var/run/php5-fpm.socket

root@app0:/# ps aux | grep fpm
root     13315  0.0  1.9 168276  4948 ?        Ss   15:51   0:00 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf
www-data 13316  0.0  2.1 168672  5492 ?        S    15:51   0:00 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf

root@app0:/# ps aux | grep nginx
root     13341  0.0  0.4  33200  1036 ?        Ss   15:52   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf
www-data 13342  0.0  0.7  34008  1880 ?        S    15:52   0:00 nginx: worker process
www-data 13344  0.0  0.6  33680  1628 ?        S    15:52   0:00 nginx: worker process

I've got a few customizations to the configurations you provide, but it's largely the same. Want to suggest a troubleshooting avenue?

zeroasterisk
  • 275
  • 1
  • 4
  • 10

3 Answers3

7

This is a gotcha that many tutorials omit. the php user should be the owner of the socket. So you want to make sure that

chown www-data:www-data /var/run/php5-fpm.socket
alfish
  • 3,127
  • 15
  • 47
  • 71
3

I don't know what caused this exactly, probably some changes in PHP code, but I've found a way to fix this:

1) Open your pool configuration as root, mine is in: /etc/php5/fpm/pool.d/www.conf

2) Add the following lines:

  • listen.owner = www-data
  • listen.group = www-data

Here's the complete documentation for all config parameters.

3) Restart PHP FPM: sudo service php5-fpm restart

It should re-create socket file with proper user and group:

ls -lah /var/run/ | grep php: -rw-r--r-- 1 root root 4 Jun 24 18:19 php5-fpm.pid srw-rw---- 1 www-data www-data 0 Jun 24 18:19 php5-fpm.sock

I hope it will help! Cheers!

Slava Fomin II
  • 1,701
  • 4
  • 17
  • 23
0

I had a similar problem. On my dev laptop (MacOS) I want to run everything in my own account, to keep it all simple. The socket i-node is owned by my own account.

I just had to comment out listen.owner and listen.group in www.conf.

I start everything in my own account with "brew services start --all".

In www.conf, 'user' is still set to '_www'. Socket is still owned by myself. Not sure why this doesn't cause an error.

Larry
  • 1