laravel – Nginx Serving Downloads of PHP Files Instead of Executing Them


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?