I installed nginx on my Lubuntu 13.04 32 bit using:

sudo apt-get install php5-fpm
sudo apt-get install mercurial libpcre3-dev libssl-dev
hg clone -r stable-1.4 http://hg.nginx.org/nginx nginx
cd nginx
auto/configure --with-http_ssl_module 
sudo make install

After it I disabled apache:

sudo kill $(pidof apache2)
sudo update-rc.d -f apache2 remove

and I edited the nginx.conf, that now is:

worker_processes  1;

    worker_connections  1024;

    include            mime.types;
    default_type       application/octet-stream;
    sendfile           on;
    keepalive_timeout  65;

        listen       80;
        server_name  localhost;
        index        index.html index.php;

        location /
            root   html;
            index  index.html index.php;

        # pass the PHP scripts to FastCGI server listening on

        location ~ \.php$
            root           html;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html
            root   html;

So I started nginx, I wrote a test.php script inside the html directory with only

    echo 'OK!';

and I opened it inside the browser, but it doesn't work. The error is:

[error] 2886#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client:, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://", host: "localhost"

php5-fpm seems to be already started, since if I try sudo php5-fpm, I get this error:

ERROR: An another FPM instance seems to already listen on /var/run/php5-fpm.sock
  • 1
    Does netstat -lpn | grep php-fpm show any output? What about iptables? – Nathan C Jun 11 '13 at 12:28
  • @NathanC: netstat returns unix 2 [ ACC ] STREAM LISTENING 13018 2168/php-fpm.conf) /var/run/php5-fpm.sock. I've no iptables rule. – Marco Sulla Jun 11 '13 at 12:38

Your PHP-FPM installation is set up to use sockets and not TCP.

Change this line:

fastcgi_pass fastcgi_pass;

To: fastcgi_pass unix:/var/run/php5-fpm/php5-fpm.sock;

Alternatively you can modify your nginx.conf file's listen = to use a port instead of the socket.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.