Updated: 18 November 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).

Run WordPress on Caddy, which handles HTTPS for you, with 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 upgrade or dnf 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

dnf module reset php && dnf module enable php:8.3
dnf install php-fpm mariadb-server php-mysqlnd php-xml php-mbstring php-gd php-intl php-opcache php-pecl-zip
systemctl enable --now php-fpm mariadb

Set user = caddy and group = caddy in /etc/php-fpm.d/www.conf and restart php-fpm.

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 caddy:caddy /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: On AlmaLinux 9 / Rocky Linux 9 SELinux is on. Let Apache/Nginx write where the application needs it, for example: semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/example.com/storage(/.*)?" && restorecon -R /var/www/example.com, and allow outgoing connections if the app calls APIs: setsebool -P httpd_can_network_connect 1.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket