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'm very much a NGINX and Server Admin beginner.

I used this tutorial to install NGINX / PHP / mySQL / WordPress:

C3M Digital Tutorial

In this tutorial the backend php-cgi setup is configured using fastcgi. php5-fpm was installed during this tutorial:

apt-get install nginx-full php5-fpm php5 php5-mysql php5-apc php5-mysql php5-xsl php5-xmlrpc php5-sqlite php5-snmp php5-curl

After reading that the NGINX configuration on the WordPress codec was more secure than most tutorials, I decided to use the codex configuration:

WordPress NGINX configuration in Codex

The Codex configuration uses php-fpm for backend php-cgi. When opening the browser I got a 502 Bad Gateway error. The error log was:

"2012/06/10 21:18:27 [crit] 14009#0: *4 connect() to unix:/tmp/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 12.3.456.789, server: mywebsite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fpm.sock:", hos t: "mywebsite.com""

In the main NGINX configuration file supplied by the codex I noticed the line starting "server unix:" in the upstream php block which point to the empty directory:

    # Upstream to abstract backend connection(s) for PHP.
upstream php {
    server unix:/tmp/php-fpm.sock;
#       server 127.0.0.1:9000;
}

I checked the folder at /tmp and it was empty.

Seems I missed configuring php-fpm to play with NGINX.

Can someone point me in the right direction?

Much appreciated!

share|improve this question
    
Is php-fpm running? –  Ladadadada Jun 10 '12 at 22:15

1 Answer 1

up vote 3 down vote accepted

Sounds like you haven't setup php-fpm to listen on the Unix socket. I'm guessing your using Debian of some sort, since the instructions you are following are for Debian.

In my Debian/nginx/php config I have this file: /etc/php5/fpm/pool.d/www.conf You need to edit this to allow php-fpm to listen on the Unix socket as opposed to the 127.0.0.1:9000 address.

Find the line in /etc/php5/fpm/pool.d/www.conf that reads listen = 127.0.0.1:9000 and change it to /tmp/php-fpm.sock (or comment it out and add the listen = /tmp/php-fpm.sock below it). Or maybe you want to store the php-fpm.sock file somewhere other than tmp. Google can probably help you with that.

share|improve this answer
    
Thank you! Sorry for the noob questions, but I have a couple: 1. what are the differences between the choices (127.0.0.1:9000 and /tmp/php-fpm.sock?) 2. are semicolons used for single line comments? Thanks. –  jw60660 Jun 10 '12 at 22:43
    
By the way, this fixed the problem. Thank you! –  jw60660 Jun 10 '12 at 22:49
    
@jw60660: 127.0.0.1:9000 uses TCP/IP to connect - it has more overhead, but is helpful in cluster scenarios (where external machines are trying to connect). /tmp/php-fpm.sock is a socket connection - it is faster with less overhead, but can't be used from an external machine. The php-fpm.conf (and associated files) are INI files - so, yes, the semi-colon is a single line comment. –  cyberx86 Jun 10 '12 at 23:02

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.