Updated: 28 September 2026 · Applies to: Debian 12
Debian 9 and 10 are no longer supported, so this guide now uses Debian 12 (Ubuntu 24.04 works the same way).
Run WordPress on Debian 12 with Caddy (automatic HTTPS), PHP-FPM and MariaDB.
Before you start
- A VPS or dedicated server with a fresh Ubuntu 24.04 / Debian 12 or AlmaLinux 9 / Rocky Linux 9 installation, and root or sudo access.
- A domain or subdomain pointing to the server (an A record), if you want HTTPS.
- The system updated:
apt update && apt upgradeordnf upgrade.
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
Install PHP and MariaDB
apt install php-fpm mariadb-server php-mysql php-xml php-mbstring php-curl php-zip php-gd php-intl mariadb-secure-installation
Create a database
mariadb -u root -p CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'Strong-Password'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost'; FLUSH PRIVILEGES; EXIT;
Download WordPress
cd /tmp && curl -O https://wordpress.org/latest.tar.gz tar xzf latest.tar.gz mkdir -p /var/www/example.com && cp -a wordpress/. /var/www/example.com/ chown -R www-data:www-data /var/www/example.com
Then open your domain in a browser and follow the installer: enter the database name, user and password you created, and create the admin account (do not call it "admin").
Caddyfile for WordPress
Edit /etc/caddy/Caddyfile:
example.com {
root * /var/www/example.com
php_fastcgi unix//run/php/php8.3-fpm.sock # unix//run/php-fpm/www.sock on AlmaLinux/Rocky
file_server
encode gzip
}
Reload with systemctl reload caddy. Caddy gets and renews the HTTPS certificate automatically once the domain points to the server and ports 80 and 443 are open.
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
Note: Debian 12's PHP socket is /run/php/php8.2-fpm.sock; adjust the Caddyfile.