Nginx – How to get PHP 5.3.3 working with Nginx on CentOS 5.5

centosnginxPHPphp-fpm

I have installed Engine X and PHP 5.3.3 from source onto a CentOS 5.5 server. I think everything went well from the installs and Engine X does serve static files OK.

When trying to access a basic php file though, it serves the php code as plain text.

The Engine X error log shows:

2010/09/23 20:49:35 [error] 3331#0: *6 connect() failed (111: Connection refused) while
connecting to upstream, client: my.local.ip, server: the_server,
request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000",
host: "the.servers.ip"

And my configuration file reads:

server {
   listen *:80;

   location ~ \.php$
   {
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_param SCRIPT_FILENAME /var/www/default$fastcgi_script_name;
       fastcgi_param PATH_INFO $fastcgi_script_name;
       include /usr/local/nginx/conf/fastcgi_params;
   }
}

Best Answer

  1. Ensure php-fpm is running (ps auxw | grep php or any number of ways)
  2. Ensure php-fpm is actually listening on 9000. (check the configs)
  3. Ensure your software firewall isn't blocking loopback connections on 9000.

I'm not an nginx guy, but the error message is pretty clear: nobody's answering the phone at 127.0.0.1:9000