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).
Install WordPress on Debian 12 with Apache, MariaDB and PHP.
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 Apache, MariaDB and PHP
Ubuntu 24.04 / Debian 12:
apt install apache2 mariadb-server php libapache2-mod-php php-mysql php-xml php-mbstring php-curl php-zip php-gd php-intl systemctl enable --now apache2 mariadb
AlmaLinux 9 / Rocky Linux 9 (choose a current PHP stream first):
dnf module reset php && dnf module enable php:8.3 dnf install httpd mariadb-server php php-fpm php-mysqlnd php-xml php-mbstring php-gd php-intl php-opcache php-pecl-zip systemctl enable --now httpd mariadb php-fpm
Secure MariaDB (set a root password or keep socket login, remove test data): 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").
Create the Apache site
Create /etc/apache2/sites-available/example.com.conf (Ubuntu/Debian) or /etc/httpd/conf.d/example.com.conf (AlmaLinux/Rocky):
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
<Directory /var/www/example.com>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Ubuntu/Debian: a2ensite example.com && a2enmod rewrite && systemctl reload apache2. AlmaLinux/Rocky: apachectl configtest && systemctl reload httpd.
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
Add a free SSL certificate
apt install certbot python3-certbot-apache # Ubuntu / Debian dnf install epel-release && dnf install certbot python3-certbot-apache # AlmaLinux / Rocky certbot --apache -d example.com -d www.example.com
Certbot installs a timer that renews the certificate automatically; test it with certbot renew --dry-run.
Debian 12 ships PHP 8.2, which current WordPress fully supports.