0

I have configured aws instance from amazon ec2 linux image and configured nginx and php on server. Server serves html pages normally but don't serve php pages and also shows 503 Bad gateway error when open in browser.

Below is my nginx server configuration

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
            try_files $uri $uri/ =404;
    }


    location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            #include snippets/fastcgi-php.conf;
            #fastcgi_pass unix:/var/run/php5-fpm.sock;
            include fastcgi_params;
    }

}

I have also configured php-fpm. Below are the log extract from nginx error log. 2016/07/05 13:11:34 [error] 3969#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 45.117.48.117, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "52.66.51.131" 2016/07/05 13:11:35 [error] 3969#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 45.117.48.117, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "52.66.51.131" 2016/07/05 13:11:42 [error] 3969#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 45.117.48.117, server: _, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "52.66.51.131" 2016/07/05 13:12:18 [error] 3969#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 45.117.48.117, server: _, request: "GET /phpinfo.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "52.66.51.131" I would highly appreciate any feedback on this. Also when i start php-fpm service it gives me below message

Starting php-fpm-5.6: [05-Jul-2016 13:15:20] WARNING: [pool www] ACL set, listen.owner = 'nginx' is ignored [05-Jul-2016 13:15:20] WARNING: [pool www] ACL set, listen.group = 'nginx' is ignored
                                                       [  OK  ]

Thanks

1
  • What does your PHP-FPM configuration look like? Jul 5, 2016 at 18:36

1 Answer 1

0

The default PHP FPM listens on a Unix socket. You have it commented out: #fastcgi_pass unix:/var/run/php5-fpm.sock;

If you want to use the socket, uncomment that line in your NGINX configuration to point to the proper socket.

If you want to connect to PHP via IP as you have currently configured, you will need to edit the php fpm pool settings. (default being www.conf)

Look for the listen directive and make it listen = 127.0.0.1:9000 instead of it's default value.

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.