Grav is a self-hosted, free software content management system (CMS) written in the PHP programming language and based on the Symfony web application framework. It uses a flat-file database for both the backend and frontend.
It is a good alternative to WordPress, offers a Dashboard, and has an API, a package manager, backups, and SEO capabilities.
It also has a sophisticated, automatic cache system. Compatible with memcached, redis, xcache, etc., among other interesting features.
Links
- Documentation
- GitHub repository
- Forum for support/help.
Prerequisites
An Ubuntu Server 20.04 LTS server with a root user or permissions to run sudo, and a DNS record to obtain a certificate with Certbot.
Installation
This article explains how to install Grav CMS, first installing and configuring NGINX with PHP and a Let's Encrypt certificate obtained with Certbot. Follow these steps.
Update the repository and install the updates:
# apt update && apt upgradeGo to the temporary directory and download Grav from the official website (includes the admin plugin):
# cd /tmp && wget https://getgrav.org/download/core/grav-admin/latest/grav-admin-v1.7.17.zipUnzip the downloaded file:
# apt install -y unzip && unzip grav-admin-v1.7.17.zipInstall NGINX, PHP with the Grav requirements (some optional packages), and Certbot:
# apt install nginx php-cli php-fpm php-common php-curl php-dompdf php-gd php-zip php-apcu php-yaml php-xdebug php-mbstring php-xml php-json certbot python3-certbot-nginxCheck the PHP installation and version:
# php -vSynchronize the extracted directory with webroot:
# rsync -rtv grav-admin/ /var/www/html/Change the owner and group recursively:
# chown -R www-data:www-data /var/www/html/Also modify the directory permissions:
# chmod -R 755 /var/www/html/Then edit the site file:
# vi /etc/nginx/sites-available/defaultChange server_name in the file to the subdomain or domain record:
server_name grav.ejemplo.com;Add index.php to the index line:
index index.php;Replace the try_files line with:
try_files $uri $uri/ /index.php?$args;Also uncomment the lines for using PHP and deny access to .htaccess (not used by NGINX). It will look like this:
# pass PHP scripts to FastCGI server
location ~ \.php$ {
# include snippets/fastcgi-php.conf;
include fastcgi.conf;
# fastcgi_index index.php;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
fastcgi_param HTTPS on;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
Verify the modified configuration with:
# nginx -tRestart the web service to reload the changes:
# systemctl restart nginx.serviceFinally, obtain a certificate with Certbot using redirect:
# certbot --nginx --redirect -d grav.ejemplo.comAfter this last action, you can access the admin directly over HTTPS to finish the installation by creating a user for Grav in your browser (https://grav.ejemplo.com/admin)