Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alanaasmaa's avatar

Laravel|nginx|php7|Ubuntu 16 = 502 Bad Gateway

Hello,

I'm using nginx first time (usually used apache) and i can't get it working. I rebuilded my droplet from digital ocean multible times.

I used this tutorial to set it up: https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-an-nginx-web-server-on-ubuntu-14-04

Ecept one line is fastcgi_pass unix:/var/run/php7.0-fpm.sock;

Also used this. I have also used alot of other tutorials reinstall removed and everything. I just cant get this fixed.

My domain is alanaasmaa.eu

my dir is /var/www/laravel/public


server {

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

    root /var/www/laravel/public;
    index index.php index.html index.htm;

    server_name localhost;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

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

0 likes
3 replies
alanaasmaa's avatar

No help :/

EDIT: I have tryed as much as i can find from google. I don't understand what could be wrong.

alanaasmaa's avatar
alanaasmaa
OP
Best Answer
Level 4

Changed fastcgi_pass unix:/var/run/php7.0-fpm.sock; to fastcgi_pass 127.0.0.1:9000; And now it works.

5 likes

Please or to participate in this conversation.