Installing Grav and Securing with SSL
Introduction
Grav is a modern, open-source flat-file CMS. This guide will walk you through installing Grav and securing it with SSL.
Prerequisites
- A server running Linux (e.g., Ubuntu 24.04)
- SSH access with sudo privileges
- A registered domain name
Installation Steps
-
Update System Packages:
sudo apt update && sudo apt upgrade -y -
Install Required Packages:
sudo apt install apache2 php libapache2-mod-php unzip -y -
Download Grav:
cd /var/www/html sudo wget https://getgrav.org/download/core/grav-admin/latest -O grav-admin.zip -
Extract Grav:
sudo unzip grav-admin.zip sudo mv grav-admin grav -
Set Permissions:
sudo chown -R www-data:www-data /var/www/html/grav -
Configure Apache:
sudo nano /etc/apache2/sites-available/grav.confAdd the following configuration:
<VirtualHost *:80> ServerAdmin admin@yourdomain.com DocumentRoot /var/www/html/grav ServerName yourdomain.com ServerAlias www.yourdomain.com <Directory /var/www/html/grav> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>Enable the site and rewrite module:
sudo a2ensite grav.conf sudo a2enmod rewrite sudo systemctl restart apache2
Securing with SSL
-
Install Certbot:
sudo apt install certbot python3-certbot-apache -y -
Obtain SSL Certificate:
sudo certbot --apache -d yourdomain.com -d www.yourdomain.com -
Auto-Renewal: Certbot sets up a cron job for auto-renewal. To test:
sudo certbot renew --dry-run
Conclusion
Your Grav installation is now secured with SSL. Ensure to keep your system and Grav updated.