Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Installation & Hosting

Admin page won't load after moving from apache to nginx

admin

Started by Anthony J Cervo 3 years ago · 0 replies · 574 views
3 years ago

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 (tcervo.com/admin), 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:

TXT
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.

Suggested topics

Topic Participants Replies Views Activity
Installation & Hosting · by antoinep, 19 hours ago
7 72 1 hour ago
Installation & Hosting · by Jürgen Dietrich, 7 months ago
0 65 7 months ago
Installation & Hosting · by rappluk, 8 months ago
0 65 8 months ago
Installation & Hosting · by N, 12 months ago
3 76 12 months ago
Installation & Hosting · by Youle, 1 year ago
1 64 1 year ago