This setup runs WordPress and a private MariaDB database with persistent volumes. You will create your site administrator in the browser, then publish a first page. A practical OwnServa starting estimate is 2 CPU cores and 2 GB RAM, with more capacity for busy sites or heavy plugins.
Before you start
Follow server preparation and Docker installation. Use a domain you control, such as blog.example.com, and reserve loopback port 8082. Start with a new application directory:
mkdir -p ~/selfhosted/wordpress
cd ~/selfhosted/wordpress
umask 077
openssl rand -hex 32
Generate two different secrets with the last command. Save them in .env:
DB_PASSWORD=REPLACE_WITH_FIRST_RANDOM_SECRET
DB_ROOT_PASSWORD=REPLACE_WITH_SECOND_RANDOM_SECRET
Set up MariaDB and WordPress
Save the following as compose.yaml. The database container initializes a database named wordpress and an application user with the same name when its volume is empty. WordPress connects over the private Compose network, not a public database port.
services:
db:
image: mariadb:11.4
restart: unless-stopped
environment:
MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:?set DB_ROOT_PASSWORD}
MARIADB_DATABASE: wordpress
MARIADB_USER: wordpress
MARIADB_PASSWORD: ${DB_PASSWORD:?set DB_PASSWORD}
volumes:
- database:/var/lib/mysql
healthcheck:
test: [CMD, healthcheck.sh, --connect, --innodb_initialized]
interval: 10s
timeout: 5s
retries: 12
wordpress:
image: wordpress:apache
restart: unless-stopped
ports:
- "127.0.0.1:8082:80"
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD:?set DB_PASSWORD}
volumes:
- website:/var/www/html
depends_on:
db:
condition: service_healthy
volumes:
database:
website:
The website volume keeps uploads, themes and plugins across container replacements. The database stores content and settings. Keep both. These initialization variables do not rotate credentials in an already populated database.
Start the containers and enable HTTPS
chmod 600 .env
sudo docker compose config --quiet
sudo docker compose up -d
sudo docker compose ps
sudo docker compose logs --tail=60 wordpress db
Use the shared HTTPS steps to route blog.example.com to 127.0.0.1:8082. Caddy forwards the original scheme to the official WordPress image. Complete the installer on the final HTTPS domain so WordPress saves the correct site address. Avoid installing on a temporary IP and changing URLs later.
Create your first administrator
Open https://blog.example.com. Choose a language, then enter your site title, administrator username, strong password and recovery email. This creates the WordPress administrator; it does not create an OwnServa account. Use your own username instead of a predictable shared admin login.
Complete installation, open https://blog.example.com/wp-admin/ and sign in. In Settings → General, confirm both site URLs use your HTTPS domain. Choose a permalink structure, create a page in Pages → Add New, and verify it in a signed-out browser. If you selected the option discouraging search engines during setup, clear it in Settings → Reading when the site is ready for indexing.
Keep the site recoverable
Back up MariaDB and the website volume together, plus .env. Test restoring a copy of the site. Use a real mail provider or SMTP plugin for password resets and confirm delivery. Remove unused plugins and themes, and update the remaining ones after backups. Record the image releases you use before moving to a newer version.
Troubleshooting
- Error establishing a database connection: verify
dbis healthy, the database host isdb:3306, and both services use the same application password. - Site redirects to an old hostname: check WordPress Address and Site Address. Changing DNS does not rewrite those database settings.
- Uploads fail: inspect logs and available disk space before changing ownership or permissions. Do not make the whole site world-writable.
- Reset email never arrives: test SMTP separately; a successful installation does not configure mail delivery.
Official references
See the WordPress installation handbook, the official Docker image instructions and MariaDB container documentation. This guide provides a starter deployment rather than a guarantee of capacity for a particular site.
Written by OwnServa. Check the official release notes before updating, keep independent backups and test a restore before relying on your installation.