Please help me get FastCGI working with nginx

Rt Ibmer rtibmx at
Mon Aug 4 08:26:24 MSD 2008

I've spent the past several days going around and around trying to get FastCGI working with Nginx and I am stuck. Hopefully someone here can guide me please.

In summary I am trying to use nginx to front-end a PHP web site (instead of using Apache/PHP I want to us Nginx/PHP).

I have a working nginx 0.6.latest.ver working without PHP and FastCGI support, as I've used nginx plenty in the past.  So now I am trying to add PHP and FastCGI into the picture but am totally stuck...

The first thing I did was download and compile PHP with FastCGI support:

../configure --enable-mbstring --with-mysql=/usr/bin --with-mysql-sock=/mnt/mysql/data/mysql.sock --enable-fastcgi --with-curl --enable-sockets --with-config-file-path=\etc

make install

So that goes OK.

But then when I run /usr/local/bin/php -v it says:
  PHP 5.2.6 (cli) (built: Aug  3 2008 23:45:09)
  Copyright (c) 1997-2008 The PHP Group
  Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

I read somewhere that if that output says "(cli)" and not "(fast-cgi)" then PHP is not installed with FastCGI support. So perhaps this is my issue.

However as you can see from my ./configure command for PHP included above, I am specifying --enable-fastcgi which according the several web sites and the ".configure --help" says is all that is needed.

Am I missing something here?

Then based on pages like I am doing this:
/usr/local/bin/spawn-fcgi -a -p 8888 -f /usr/local/bin/php

and it exists with this:
spawn-fcgi.c.218: child exited with: 0, Success

However when I do a "ps -A" I don't see spawn-fcgi running.  Furthermore if I telnet to port 8888 on localhost it says connection refused so I don't think anything is listening there.

So then of course when I try a .php page on nginx I get this in its error log:
connect() failed (111: Connection refused) while connecting to upstream, client: x.y.z.a, server: localhost, request: "GET /test.php5 HTTP/1.1", upstream: "fastcgi://", host: "myhost"

Can someone please point me in the right direction? Any tips are GREATLY appreciated!  Also is there any chance we will get FastCGI natively implemented in nginx like it is with Apache and other servers? Thank you so much in advance!!


More information about the nginx mailing list