Installing GravCMS on Ubuntu 24.04

grav cms Grav Ubuntu 24.0.4

Alt text

Installing Grav CMS on Ubuntu Server 24.04 (Apache). Grav is by far my favorite CMS I have ever used! Installing Grav CMS on Ubuntu Server 24.04 (Apache) is refreshingly straightforward. Grav is hands-down my favorite CMS, mostly because it skips the usual baggage no database, no heavy backend, just clean files.

Pages are Markdown, styling is just CSS. It’s fast, flexible, and doesn’t fight you when you want to tweak things or version-control the site. I like 👍

This is intended to be a single, clean, repeatable install guide

Assumptions

  • You are root (no sudo anywhere)

  • Fresh Ubuntu Server 24.04 LTS

  • Apache + PHP 8.3

  • Install path: /var/www/grav

Sanity check

lsb_release -a
whoami

Expected:

  • Ubuntu 24.04

  • root

Install Apache + PHP 8.3

apt update
apt install -y apache2 unzip curl git rsync \
  php8.3 php8.3-cli php8.3-common php8.3-curl php8.3-gd php8.3-intl \
  php8.3-mbstring php8.3-xml php8.3-zip php8.3-opcache php8.3-apcu \
  libapache2-mod-php8.3

Enable required Apache modules:

a2enmod rewrite headers expires deflate env mime setenvif
systemctl enable --now apache2

Fix Apache ServerName warning (recommended)

Prevents:
AH00558: Could not reliably determine the server's fully qualified domain name

echo "ServerName localhost" > /etc/apache2/conf-available/servername.conf
a2enconf servername
apache2ctl configtest
systemctl reload apache2

Download Grav

Option A — Grav Core (recommended, minimal)

cd /var/www
rm -rf grav
curl -L -o grav.zip https://getgrav.org/download/core/grav/latest
unzip grav.zip
rm -f grav.zip

Option B — Grav + Admin UI

cd /var/www
rm -rf grav
curl -L -o grav-admin.zip https://getgrav.org/download/core/grav-admin/latest
unzip grav-admin.zip
rm -f grav-admin.zip

Permissions (this matters, it got me for a sec)

Apache user on Ubuntu = www-data

chown -R www-data:www-data /var/www/grav
find /var/www/grav -type d -exec chmod 755 {} \;
find /var/www/grav -type f -exec chmod 644 {} \;

Writable Grav directories:

chmod -R 775 /var/www/grav/cache /var/www/grav/logs /var/www/grav/images /var/www/grav/tmp
chown -R www-data:www-data /var/www/grav/cache /var/www/grav/logs /var/www/grav/images /var/www/grav/tmp

Apache VirtualHost

Create site config:

cat >/etc/apache2/sites-available/grav.conf <<'EOF'
<VirtualHost *:80>
    ServerName grav.local
    DocumentRoot /var/www/grav

    <Directory /var/www/grav>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/grav_error.log
    CustomLog ${APACHE_LOG_DIR}/grav_access.log combined
</VirtualHost>
EOF

Enable site:

a2ensite grav.conf
a2dissite 000-default.conf
apache2ctl configtest
systemctl reload apache2

Verify

curl -I http://127.0.0.1/

Expected:

  • HTTP/1.1 200 OK

Browser:

  • http://<server-ip>/ Admin user (Admin install only)
cd /var/www/grav
bin/gpm install admin -y
bin/plugin login newuser

Admin UI:

  • http://<server-ip>/admin

Common Failures I encountered

PHP loaded into Apache

apache2ctl -M | grep php

If missing:

a2enmod php8.3
systemctl restart apache2

Pretty URLs broken

a2enmod rewrite
systemctl reload apache2

Pages downloading instead of rendering

PHP module missing:

apt install -y libapache2-mod-php8.3
systemctl restart apache2

Optional HTTPS (Let’s Encrypt)

apt install -y certbot python3-certbot-apache
certbot --apache

What to back up

  • Content: /var/www/grav/user/

  • Config: /var/www/grav/user/config/

  • Plugins/Themes: /var/www/grav/user/plugins/, /var/www/grav/user/themes/

Quick full backup:

tar -C /var/www -czf /root/grav-backup.tgz grav

End state

This should get you to a fully installed GRAV CMS on Ubuntu 24.04. I have a lot of love for Grav. It fits most people’s needs, is fast, light on resources, requires no database, and is endlessly customizable. I self-host my sites using Cloudflare tunnels. Grav caches, Cloudflare tunnels cache, Grav uses low resources. It's a winning combo 😉

Thanks for reading! -Christian

Previous Post Next Post