Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Nginx gives bad 502 gateway, the log says

*205 connect() failed (111: Connection refused) while connecting to upstream

And sure enough, the 9000 socket isn't open.

The problem is: I don't know how to open this port. Other questions address this issue for php-fpm, suggesting to use a unix socket. However this doesn't seem applicable here because there is no php-fpm.conf for php-5.3.3.

I am using centos 5.3.

share|improve this question

You can install the remi repo which contains php 5.3.x and php-fpm, and allows you to maintain everything in your package manager. I have used this repo for CentOS versions 5.7 all the way to 6.3. You are more than available to compile php-fpm via the instructions provided here and follow the instructions for the ini configuration here, but I find them highly over complicated, and difficult to maintain as they are outside of package management.

Enterprise Linux 5 (with EPEL)

rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

Enterprise Linux 6 (with EPEL)

rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

Once you have this repo installed, you will be able to search the repo so that you can find whatever PHP you need.

[root@puppetmaster ~]# yum list php.x86_64 --enablerepo=remi
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * remi:
 * updates:
Available Packages
php.x86_64                                               5.3.18-1.el6.remi                                               remi

[root@puppetmaster ~]# yum list php-fpm --enablerepo=remi
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * remi:
 * updates:
Available Packages
php-fpm.x86_64                                             5.3.18-1.el6.remi                                             remi

You are more than able to search for anything that you may need to get out of the repo, whether it be mbstring, mcrypt, mysql, mysqlnd.

Once you have everything installed to your wishes, you can simply start php-fpm like you would any other service.

[root@puppetmaster ~]# service php-fpm start
Starting php-fpm:                                          [  OK  ]

You will need to configure nginx to know what the upstream is, this can be done via nginx.conf inside the http {} level of the config, by default php-fpm will start using port 9000

[root@puppetmaster ~]# netstat -na | grep 9000
tcp        0      0    *                   LISTEN

You can change how your pool is created by editing your [something] pool to reflect something like this.

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   ''    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen =

The below allows you to create an alias that you can use to simple the readability of your configs.

upstream  base_backend {
    #server unix:/var/run/php-fpm.sock;

You can direct your PHP scripts inside your server {} level of the config so that php-fpm will actual execute them.

location ~ \.php$ { ## Execute PHP scripts
    expires        off; ## Do not cache dynamic content
    fastcgi_pass   base_backend;
    fastcgi_param  HTTPS $fastcgi_https;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params; ## See /etc/nginx/fastcgi_params
share|improve this answer

You can install FPM on CentOS by several ways:

  1. You can install additional repository and install php-fpm package from it (for example, it is described here)
  2. Or you can install php-fpm from source (all steps are provided here, but this blog is on Russian, so you have to use Google Translate).
share|improve this answer
1. seems to be for centos 5.8 – Adripants Oct 30 '12 at 10:27

Port 9000 need to connect to a php-fpm daemon. Sounds like php-fpm is not started.

Check your ps listing to see if php-fpm is there. Also, you mention a "socket". PHP fpm supports unix sockets, but the setup is different from TCP.

share|improve this answer

Your Answer


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.