Error with php (fcgi) on ubuntu hardy

Hi I tried to setup an ubuntu server with nginx that is serving php
sites with php fcgi.

I set up my config files like this:

server {
listen 80;
server_name XXXXX;

    access_log  /var/log/nginx/localhost.access.log;

    location / {
            root   /var/www/nginx-default;
            index  index.html index.htm;
    }

    location ~ \.php$ {
            include        /etc/nginx/fastcgi_params;
            fastcgi_pass   127.0.0.1:9000;
    }

}

and I started php with the following command:

php-cgi -b 127.0.0.1:9000

My fastcgi_params file looks like:

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

PHP only, required if PHP was built with --enable-force-cgi-redirect

fastcgi_param REDIRECT_STATUS 200;

Now I want to access a php page. But all I get is an 502 Bad Gateway
Error. I know this means that something is wrong with the fcgi server -
so I tried to find a hint in the error.log of nginx where I found this:

2009/12/16 01:36:59 26057#0: *1 connect() to 127.0.0.1:9000 failed (22:
Invalid argument) while connecting to upstream, client: XXXXX, server:
XXXXX, URL: “/index.php”, upstream: “fastcgi://127.0.0.1:9000”, host:
“XXXXX”

This confused me because I don’t understand this error message and also
found no hint of something similiar with google. So maybe you have a
cool idea that is taking me out of this misconfiguration.

I would be really happy if this works - I want to leave apache as fast
as possible. Thanks!
Gregor

Posted at Nginx Forum: