My Grav site has been up and running for a couple years now (Digitial Ocean, Ubuntu 20). It’s been running fine on apache, but for other reasons I want to migrate to nginx. I got nginx configured and running, turned off apache, copied the sample nginx.conf file to /etc/nginx/sites-avaiable/tcervo.com (and made the symlink in sites-enabled). The site comes up fine, all posts work fine, tags (which I’m using for the main navigation) work fine, etc. But, when I try to load the admin screen (Grav Admin Login | Tony Cervo), it just downloads the file instead of loading the page. Note: it doesn’t give me a “page not found” error, it just stays on whatever page I was on, and downloads a file named “admin” that is a php file. But, index.php is working, so I’m confused why admin doesn’t work.
Here’s my site’s config file:
server {
listen 80;
listen [::]:80;
index index.html index.php;
root /var/www/tcervo.com/public_html;
server_name tcervo.com www.tcervo.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
location ~* /(system|vendor)/.*\.(txt|xml|md|html|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
location ~* /user/.*\.(txt|md|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }
location ~ \.php$ {
# Choose either a socket or TCP/IP address
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
# fastcgi_pass unix:/var/run/php5-fpm.sock; #legacy
# fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
}
Any ideas? Thanks.