Grav is a self-hosted, free and open-source 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, offering a Dashboard, an API, a package manager, backups, and SEO capabilities.
It also has a sophisticated, automatic cache system. It supports memcached, redis, xcache, etc., among other interesting features.
Links
- Documentation
- GitHub repository
- Forum for support/help.
Prerequisites
An Ubuntu Server 24.04 LTS server with a root user or sudo privileges, and a DNS record to obtain a certificate with Certbot.
Installation
This article explains how to install Grav CMS, starting with installing and configuring NGINX with PHP and a Let's Encrypt certificate obtained using Certbot. Follow the steps below and run the indicated commands.
Update the repository and install the updates:
# apt update && apt upgrade -yGo to the temporary directory and download Grav from the official website (includes the admin plugin):
# cd /tmp && wget -O grav-admin.zip https://getgrav.org/download/core/grav-admin/latestExtract the downloaded file:
# apt install -y unzip && unzip grav-admin.zipInstall NGINX, PHP with the packages required by Grav (some packages are optional), and Certbot:
# apt install nginx php-cli php-fpm php-common php-curl php-gd php-zip php-apcu php-yaml php-xdebug php-mbstring php-xml php-json certbot python3-certbot-nginx -yCheck the PHP installation and version:
# php -vSynchronize the extracted directory with the webroot:
# rsync -rtv grav-admin/ /var/www/html/Change the owner and group recursively:
# chown -R www-data:www-data /var/www/html/Also change 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;Change the try_files line to:
try_files $uri $uri/ /index.php?$args;Also uncomment the lines for PHP support and deny access to .htaccess (not used by NGINX). It will look like this:
# Pass PHP scripts to the 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/php8.3-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
# matches nginx's document root
#
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 and enable redirection:
# certbot --nginx --redirect -d grav.ejemplo.comAfter this last step, you can access the admin directly over HTTPS to complete the installation by creating a Grav user in your browser (https://grav.ejemplo.com/admin)
Congratulations! Grav is now installed on your server.
Remember, if you have any questions about this or any other issue related to your servers on Clouding, feel free to email soporte@clouding.io We’re here for whatever you need. Just ask!