Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I setup a system similar to the tutorial here: http://vladgh.com/blog/varnish-nginx-and-php-533-ubuntu-1010

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?

share|improve this question
    
Nevermind - I figured out a key configuration I was missing for nginx. –  zeroasterisk Apr 14 '11 at 16:08
1  
PLEASE tell what the heck was the problem... –  Smar Apr 11 '12 at 11:59
add comment

2 Answers 2

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
share|improve this answer
    
And how do I persist this change? Every time php5-fpm is reloaded it creates socket with root as an owner. –  Slava Fomin II Jun 24 at 22:06
add comment

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!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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