About

This is a brief description of yourself or your site, to change this text go to the admin panel, settings, plugins, and configure the plugin "about".

Static Pages

GRAV with NGINX, Debian 12


Install, PHP, DB, Nginx first.

$ adduser nginx
$ adduser nginx sudo
$ su - nginx
$ exit

$ cd /var/www/html
$ sudo wget https://getgrav.org/download/core/grav-admin/1.7.48
$ sudo unzip 1.7.48
$ sudo mv grav-admin grav
$ sudo chown -R www-data:www-data /var/www/html/grav

Nginx Config File

$ sudo nano /etc/nginx/conf.d/grav.conf

server {
listen 80;
server_name grav.example.com;
root /var/www/html/grav;
index index.html index.php;
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|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
   location ~* /user/.*\.(txt|md|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$ {
   fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   fastcgi_index index.php;
   include fastcgi_params;
   fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
 }
}

$ sudo nginx -t
$ sudo systemctl restart nginx
$ sudo systemctl status nginx

If you find issues with the scheduler in Grav, run the following command:
$ sudo crontab -u www-data -e
And add this line to the bottom of the file:
cd /var/www/html/grav;/usr/bin/php bin/grav scheduler 1>> /dev/null 2>&1