0

For some reason, I am unable to get my website working. I have followed all the steps from DevMarketer Laravel website deployment, but I am getting the following error:

502 Bad Gateway
nginx/1.16.1 (Ubuntu)

I am aware there is a problem with the configuration of Nginx, but after seeing many answers from similar problems, I was unable to get this working. Below, is my nnginx.conf file:

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

    root /var/www/mydomain/public;

    index index.php index.html index.htm;

    server_name mydomain.com;

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

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass 127.0.0.1:9000;
    }

    location ~ /\.ht {
            deny all;
    }
}

FastCGI-php.conf

# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+?\.php)(/.*)$;

# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php;
include fastcgi.conf;

My Laravel website includes a database and runs on PHP 7.3. The server provider is called Vultr.

Help will be much appreciated.

georgios
  • 1
  • 1
  • The error message indicates that the backend is not working, so check that the fastcgi process is running. Edit your question to add info about the fastcgi stuff, including the fastcgi-php.conf file. – wurtel Nov 12 '19 at 14:53
  • Updated. Please let me know. – georgios Nov 12 '19 at 15:03
  • Is the fastcgi process running? Try `netstat -tnl | grep :9000`, that should show one line. Do you know what flavour of cgi process you're running? Try `dpkg -l | grep cgi` – wurtel Nov 13 '19 at 07:57
  • Hi, I tried running those commands but I don't get anything. This is what I get: `root@User:~# netstat -tnl | grep :9000 root@User:~# dpkg -l | grep cgi root@User:~#` – georgios Nov 13 '19 at 08:24
  • So nothing is listening to port 9000. You probably have php-fpm and not something with "cgi" in the name, sorry. Why do you have `fastcgi_pass 127.0.0.1:9000;` in your nginx config when the laravel site says to use `fastcgi_pass unix:/run/php/php7.0-fpm.sock;` ? – wurtel Nov 13 '19 at 15:31
  • Hi, thanks for the advice. Now I am getting a 500 error. It seems like my laravel code fails at some point. Do you have any tips on how to get the error log? – georgios Nov 15 '19 at 16:29

0 Answers0