Weasler
Weasler

Reputation: 247

NGinx Laravel 4 - 502 Bad Gateway Error

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

        root /home/thinkshare/public/;
        index index.php;

        server_name domain_here;

        location / {
                try_files $uri $uri/ /index.php$is_args$args;
        }

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

Here is my current NGinx configuration - I cannot for the life of me figure out what exactly is happening to warrent a 502 Gateway Error on connection, domain or IP direct. Any thoughts?

edit

Removed Domain

Upvotes: 0

Views: 3658

Answers (3)

chuixue
chuixue

Reputation: 317

In Ubuntu 16.04 I get this error too. I resolved it by editing the /etc/php/7.0/fpm/pool.d/www.conf

user = yourname
group = yourgroup

listen.owner = yourname
listen.group = yourgroup

and restart php7.0fpm by the use of $sudo service php7.0-fpm restart

This error is due to your path isn't in default /var/www which is owned by www-data when you in other directory, you should set it!

Upvotes: 0

user1600649
user1600649

Reputation:

Permissions for the socket are incorrect and the reason why changing to top solved it

Upvotes: 0

Weasler
Weasler

Reputation: 247

I was able to finally find the answer at this link.

Effectively, fastcgi_pass in the nginx file as well as listen in the fpm file needs to be changed to 127.0.0.1:9000.

Upvotes: 1

Related Questions