Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 
make
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;

events
{
    worker_connections  1024;
}


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

    server
    {
        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 127.0.0.1:9000

        location ~ \.php$
        {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            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

<?php
    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: 127.0.0.1, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", 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
share|improve this question
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. –  Lucas Malor Jun 11 '13 at 12:38
add comment

1 Answer

up vote 0 down vote accepted

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

Change this line:

fastcgi_pass fastcgi_pass 127.0.0.1:9000;

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.

share|improve this answer
    
It works :) PS: despite of what php5-fpm and netstat say, my socket is in /run/php5-fpm.sock , and this is the reason: askubuntu.com/questions/57297/… –  Lucas Malor Jun 12 '13 at 7:38
add comment

Your Answer

 
discard

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.