简体   繁体   中英

502 Bad Gateway in nginx/1.4.6 (Ubuntu14 Digital Ocean)

I'm install PHP7.0, Nginx1.4.6 and configured as below but I got many errors.

sudo nano /etc/php/7.0/fpm/pool.d/www.conf

#listen = /run/php/php7.0-fpm.sock
#listen = /var/run/php/php7.0-fpm.sock
listen = 127.0.0.1:9000
user = www-data
group = www-data
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

server {
#       listen 80 default_server;
        listen 80;
        listen [::]:80 default_server ipv6only=on;

        location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_pass 127.0.0.1:9000;
        #fastcgi_index index.php;
        #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

Let see the Log:

2017/01/26 03:33:54 [error] 2976#0: *8 connect() failed (111: Connection refused) while connecting to upstream, client: 96.9.77.42, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "128.199.133.1$
2017/01/26 03:33:55 [error] 2976#0: *8 connect() failed (111: Connection refused) while connecting to upstream, client: 96.9.77.42, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "128.199.133.1$
2017/01/26 03:33:55 [error] 2976#0: *8 connect() failed (111: Connection refused) while connecting to upstream, client: 96.9.77.42, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "128.199.133.1$

you may need to set listen.allowed_clients to 127.0.0.1 & comment group & user sections

# only localhost can connect to PHP-FPM
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
# listen.owner = www-data
# listen.group = www-data

then restart php-fpm service, check if it is running on port 9000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM