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

I've received my very first VPS just today, and wanted to install a nginx + PHP + MariaDB setup on it. And, well, I actually did it, but I've got a problem configuring it.

Getting nginx to serve a static .html-file was no problem, trying to serve a dynamic PHP-file however just shows a public "502 Bad Gateway" message. My interpretation of the nginx logfile indicates a communication error between nginx and PHP-FPM, but I'm a bloody newbie, so that can be incredibly wrong.

php5-fpm.log:

[05-Aug-2012 21:50:10] NOTICE: fpm is running, pid 10982
[05-Aug-2012 21:50:10] NOTICE: ready to handle connections

part of nginx's error.log:

2012/08/06 00:13:20 [error] 11419#0: *4 connect() failed (111: Connection refused) while connecting to upstream, client: REMOVED, server: lo$
2012/08/06 00:23:21 [error] 11419#0: *9 connect() failed (111: Connection refused) while connecting to upstream, client: REMOVED, server: lo$
2012/08/06 00:23:22 [error] 11419#0: *9 connect() failed (111: Connection refused) while connecting to upstream, client: REMOVED, server: lo$
2012/08/06 00:23:23 [error] 11419#0: *9 connect() failed (111: Connection refused) while connecting to upstream, client: REMOVED, server: lo$

I've lookes through most configurations, but I left almost everything default in the first place. PHP-FPM runs still on port 9000, the one nginx is supposed to query...

share|improve this question
    
Post the relevant part of your nginx config. –  Michael Hampton Aug 5 '12 at 20:48

1 Answer 1

up vote 2 down vote accepted

This is a long shot (as I don't know your distribution, versions or config), but if I remember correctly recent default configurations of PHP-FPM (at least here on Debian) switched to file-based communication (UNIX sockets) instead of TCP.

You might verify that by inspecting PHP-FPM's config file, or using lsof, netstat -a or the likes.

Edit: Just checked with my setup. I'm using Apache here, so that won't help directly, but the line for FastCGI configuration reads:

FastCgiExternalServer /var/run/apache2/php5.fcgi -idle-timeout 600 -flush -socket /var/run/php5-fpm.sock

As you can see it's referring to a socket file, namely /var/run/php5-fpm.sock.

share|improve this answer
    
Thanks! That completely nailed it down. That is something I just scrolled over, because I am used to IPs and ports, not to sockets. –  Big-Blue Aug 5 '12 at 21:10
    
UNIX sockets are generally faster than TCP (reduced overhead). So common setups (FPM on the same system as the web-server requesting it to process files) benefit from that default setting. I haven't come across a use case where I had to put the FPM-service on a different machine, but that's my POV ;). –  Alex Aug 5 '12 at 21:16

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.