Updated: 28 September 2026 · Applies to: AlmaLinux 9 / Rocky Linux 9
CentOS 7 reached end of life on 30 June 2024, so this guide now uses AlmaLinux 9 / Rocky Linux 9 (the steps also suit other RHEL 9 rebuilds).
Caddy is a modern web server that sets up HTTPS automatically with free certificates.
Install Caddy
Ubuntu 24.04 / Debian 12 (official Caddy repository):
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list apt update && apt install caddy
AlmaLinux 9 / Rocky Linux 9:
dnf install 'dnf-command(copr)' dnf copr enable @caddy/caddy dnf install caddy systemctl enable --now caddy
Open the firewall
ufw allow 80,443/tcp # Ubuntu / Debian with UFW firewall-cmd --permanent --add-service=http --add-service=https && firewall-cmd --reload # AlmaLinux / Rocky
Serve a static site
example.com {
root * /var/www/example.com
file_server
}
Put this in /etc/caddy/Caddyfile and run systemctl reload caddy.