0

I have a Laravel app I'm trying to serve with Nginx but when I navigate to my domain, all I get is a file called "download" which downloads automatically, with the content's of Laravel's public/index.php. No Laravel app is being served. Here's my server block:

server {
    server_name example.com;
    listen 443 ssl;
    listen [::]:443 ssl;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    return 301 https://www.example.com$request_uri;
}

server {
    server_name www.example.com;
    listen 443 ssl;
    listen [::]:443;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    root /var/www/example.com/public;
    index index.html index.htm index.nginx-debian.html index.php;
    location / {
            try_files $uri $uri/ =404;
    }
}

If I open the "download" file, it has the contents of Laravel's public/index.php file.

How can I configure my server block to serve my Laravel app?

GTS Joe
  • 199
  • 2
  • 10

1 Answers1

1

First make your self familiar with what PHP is.

Understand that Nginx is only a Webserver and not an php Applicationserver.

You probably want something like php-fpm.

Then in the Official Nginx Documentation you will find, how to best configure your Webserver

Ben
  • 160
  • 9