How to Install Grav CMS with Nginx on Ubuntu 20.04 – 22.04



How to Install Grav CMS with Nginx on Ubuntu 20.04 – 22.04

How to Install Grav CMS with Nginx on Ubuntu 20.04 - 22.04

Grav is a free, open-source, and flat-file CMS that does not require any database. It is based on PHP and offers several features that may not be available to other CMS like, WordPress, Joomla, etc. It is simple, easy to use, and comes with some of the key technologies including, Twig Templating, Markdown, YAML, Parsedown, Doctrine Cache, Gregwar Image Library, and Symfony Console.

In this video, I will show you how to install Grav CMS with Nginx and Let’s Encrypt SSL on Ubuntu 20.04 – 22.04 server.

Useful Links:
VPS/VDS – https://www.mivocloud.com/

WARNING – ANGLED BRACKETS AREN’T ALLOWED IN DESCRIPTION SO BE ATTENTIVE TO THE VIDEO IN NANO EDITOR

Commands Used:
apt-get install nginx php php-cli php-fpm php-common php-curl php-gd php-json php-mbstring php-xml php-zip php-opcache php-apcu unzip -y
php –version
nano /etc/php/8.1/fpm/php.ini
systemctl restart php8.1-fpm
cd /var/www/html
wget https://getgrav.org/download/core/grav-admin/1.7.17
unzip 1.7.17
mv grav-admin grav
chown -R www-data:www-data /var/www/html/grav
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.1-fpm.sock;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}

}

nginx -t
systemctl restart nginx
systemctl status nginx