VPSGauge

How to Self-Host WordPress on a VPS (Docker Compose + Caddy)

Updated Nov 24, 2026 · by Kane · how we check

Part of Self-hosting, our guide to this topic

Live data the 3 prices on this page come from 3 providers' own sites, read daily. Last read Dec 4, 2026 · no price changes in our tracking.

Short answer

To self-host WordPress, rent a Linux VPS and run the free WordPress software from wordpress.org in Docker Compose, with a MariaDB database and a Caddy reverse proxy that handles HTTPS. Budget about an hour for the setup, then a small weekly routine of updates and backups after that. A 2 GB VPS is enough for one or a few small sites, and starts at about $2.33 a month in our data.

Time
1 hr
Steps
8
Works on
Ubuntu
24.04 LTS
On this page
  1. What “self-hosted WordPress” actually means
  2. Who should not self-host WordPress
  3. What you need before you start
  4. What a small WordPress VPS costs
  5. How to self-host WordPress on Ubuntu 24.04: 8 steps
    1. 1Point a subdomain at your server
    2. 2Install Docker
    3. 3Create the project folder and the .env file
    4. 4Write the Docker Compose file
    5. 5Configure Caddy for HTTPS
    6. 6Open the firewall and start the stack
    7. 7Replace WP-Cron with a real cron job
    8. 8Back up the database and wp-content, then test the restore
  6. Key takeaways
  7. A VPS for this guide
  8. Hardening WordPress on a VPS
  9. Common self-hosted WordPress problems
  10. Questions

This guide has no affiliate links in the steps.

Before you touch a server, know what you are signing up for. “Self-hosting” here means you own the whole stack — PHP, the database, the web server, the updates, the backups — instead of renting that from WordPress.com or a shared host. The pattern is the same one as self hosting n8n: Docker Compose behind Caddy. If you have never logged into a server before, work through our new VPS setup checklist first — a sudo user, key login and a firewall come before any site.

A server rack running three stacked blocks — a reverse proxy, the publishing app and a database with its disk — linked to a laptop, tablet, phone and the internet, drawn in ink and orange on paper white.

What “self-hosted WordPress” actually means

Two things share the WordPress name, and the confusion trips up almost every beginner:

  • WordPress (the software) lives at wordpress.org. It is free, open-source publishing software you download and install yourself, on any server you control. When people say “self-hosted WordPress”, this is what they mean.
  • WordPress.com is a for-profit hosted service run by Automattic. It runs the same software for you, with some extra plugins and changes layered on. On WordPress.com you do not run or maintain a server.
TWO THINGS NAMED WORDPRESS wordpress.org free, open-source software you download and install it your VPS Docker + MariaDB = self-hosted wordpress.com a hosted service no server for you to run runs it for you run by Automattic = hosted
TWO THINGS NAMED WORDPRESS wordpress.org free software · download + install your VPS Docker + MariaDB = self-hosted wordpress.com hosted service · no server to run runs it for you run by Automattic = hosted

WordPress.org keeps a documentation page spelling out the difference. It even uses the name “self-hosted WordPress” for the software, to tell it apart from the service: the .org is the software, the .com is one hosted service built on it. This guide is about the software on a VPS you rent.

Who should not self-host WordPress

Self-hosting is a second job. You are responsible for updates, HTTPS certificates, backups and keeping the site online, and when a plugin update breaks the site at 2 a.m. there is no support ticket that fixes it for you. Skip the VPS route if any of these fit:

  • You want to write, not administer. A managed WordPress host or shared hosting keeps the server off your plate. On a VPS, an unmanaged plan hands you the operating system and everything on top of it.
  • You will not keep up with updates. WordPress core updates are easy, but every theme and plugin is a small door you must keep patched.
  • You need it to “just work” through traffic spikes. A shared or managed host usually absorbs those for you; on your own 2 GB box, a spike is your problem to watch.

If you are still here, the setup below is what a VPS gets you: full control of the files and database, no per-plugin upsells, and a site you can move anywhere.

What you need before you start

  • A VPS with Ubuntu 24.04 and a sudo user. The commands assume you can SSH in; if not, read how to SSH into a VPS first.
  • A domain where you can add DNS records.
  • SSH keys and a firewall, done first. WordPress will hold your site’s admin account, so turn on UFW and finish the new VPS setup checklist before you install anything.

How big a server? WordPress publishes software requirements, not a RAM number. Its requirements page recommends PHP 8.3 or newer and MariaDB 10.11 or newer (or MySQL 8.4). It says WordPress still runs on PHP 7.4 and MySQL 5.5.5, but those versions are end-of-life and can leave the site open to security holes. The images below give you PHP 8.3 and MariaDB 11.4, so both lines are covered.

wordpress.org requirements page: to run WordPress, it is recommended your host supports PHP version 8.3 or greater, and MariaDB version 10.11 or greater or MySQL version 8.4 or greater. The recommended versions, not the legacy minimums; HTTPS support is dimmed below. Source: wordpress.org, captured Nov 20, 2026.

For a small site — a blog or a business page with modest traffic — we size the plans in this guide at 2 GB of RAM, so WordPress, MariaDB and Caddy have room to run side by side. WordPress does not publish a memory figure, so we are not going to invent a benchmark for you.

What a small WordPress VPS costs

WordPress itself is free; you pay for the server. Three small plans from our daily data, all with the billing term spelled out and no first-year trick:

  • RackNerd 2.5 GB KVM VPS — 2 vCPU, 2.5 GB, 30 GB at $2.33/month, billed yearly. It is a Black Friday 2026 special, and RackNerd’s FAQ says the specials renew at the same rate, so the low figure is not an intro offer. Catch: you pay 12 months up front, there are no refunds by default, and RackNerd only shows the locations at checkout.
  • netcup VPS nano G11.5s — 2 vCPU, 2 GB, 60 GB at $3.36/month before VAT, on a 6-month minimum term (a public IPv4 is included in that price). Catch: every netcup plan has a minimum term, and it asks for ID verification or a prepayment after your first order.
  • InterServer 1 slice — 1 vCPU, 2 GB, 40 GB at $3.00/month, billed monthly with no term, so you can leave whenever you like. Catch: no refunds by default, and it auto-renews until you cancel.

We do not track shared-hosting prices, so we will not hand you a made-up “shared hosting renews at X” comparison. The honest version: shared and managed WordPress hosts often advertise a low first-term price that renews higher, while the VPS plans above show the steady price in our data.

How to self-host WordPress on Ubuntu 24.04: 8 steps

The commands follow the official WordPress image on Docker Hub and the MariaDB image docs. Replace YOUR_DOMAIN and the other orange words with your own values.

BROWSER YOUR VPS wp.example.com https only 443 CADDY ports 80, 443 gets the cert WORDPRESS wordpress:80 Apache + PHP MARIADB db:3306 wp_data site files uploads · themes db_data database back up both volumes port 8080 from the internet bound to 127.0.0.1 only
BROWSER wp.example.com https only 443 YOUR VPS CADDY ports 80, 443 WORDPRESS wordpress:80 Apache + PHP MARIADB db:3306 wp_data site files db_data database back up both volumes 8080 bound to 127.0.0.1 only
1

Point a subdomain at your server

At your DNS provider, add an A record named wp that points to YOUR_SERVER_IP. WordPress runs on its own subdomain, such as wp.example.com. Do this first — Caddy can only get a certificate once the name resolves to your server.

servergetent hosts wp.YOUR_DOMAIN

Check: Your server’s IP next to the name. If nothing prints, wait a few minutes and try again.

2

Install Docker

Use Docker’s own repository so you get a current version plus the Compose plugin. Our Docker on Ubuntu guide walks through the whole install; the short version is the two checks below.

serversudo docker run hello-world
sudo docker compose version
3

Create the project folder and the .env file

Make the folder, then generate two long passwords — one for the WordPress database user, one for the MariaDB root account. Run this twice:

serversudo mkdir -p /opt/wordpress/caddy_config
cd /opt/wordpress
openssl rand -base64 24

Put both passwords in an env file so they stay out of the compose file:

serversudo nano /opt/wordpress/.env
.env — nanoDOMAIN=YOUR_DOMAIN
DB_NAME=wordpress
DB_USER=wordpress
DB_PASSWORD=YOUR_WORDPRESS_DB_PASSWORD
DB_ROOT_PASSWORD=YOUR_MARIADB_ROOT_PASSWORD

Then lock the file down so other users on the box can’t read it:

serversudo chmod 600 /opt/wordpress/.env
4

Write the Docker Compose file

serversudo nano /opt/wordpress/compose.yaml
serverservices:
  caddy:
    image: caddy:2
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - caddy_data:/data
      - ./caddy_config/Caddyfile:/etc/caddy/Caddyfile:ro

  db:
    image: mariadb:11.4
    restart: unless-stopped
    environment:
      MARIADB_DATABASE: ${DB_NAME}
      MARIADB_USER: ${DB_USER}
      MARIADB_PASSWORD: ${DB_PASSWORD}
      MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
    volumes:
      - db_data:/var/lib/mysql

  wordpress:
    image: wordpress:php8.3-apache
    restart: unless-stopped
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: ${DB_USER}
      WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
      WORDPRESS_DB_NAME: ${DB_NAME}
      WORDPRESS_CONFIG_EXTRA: "define('DISABLE_WP_CRON', true);"
    volumes:
      - wp_data:/var/www/html
    ports:
      - "127.0.0.1:8080:80"

volumes:
  caddy_data:
    name: wordpress_caddy
  db_data:
    name: wordpress_db
  wp_data:
    name: wordpress_wp

What matters here:

  • WORDPRESS_DB_HOST: db points WordPress at the db service name; the two containers talk over Docker’s internal network, so the database is never exposed to the internet.
  • WORDPRESS_CONFIG_EXTRA is PHP that the image’s own wp-config.php runs on every request. Here it turns off WordPress’s built-in per-visit cron; step 7 replaces it with a real one.
  • HTTPS behind Caddy needs no extra code. The image’s wp-config.php already switches WordPress to HTTPS when the proxy sends X-Forwarded-Proto: https, so it builds https:// links. Don’t paste a PHP block with $_SERVER into the compose file: Compose treats $ as a variable and quietly breaks the code.
  • 127.0.0.1:8080:80 binds WordPress to the server only. Docker-published ports bypass ufw, so a plain 8080:80 would be open to everyone; Caddy reaches WordPress over the internal network either way.
  • The name: lines pin the volume names, so the backup commands in step 8 can refer to wordpress_db and wordpress_wp without guessing Docker’s project prefix.

Docker Hub page of the official wordpress image: the environment variables honored for configuring WordPress, with WORDPRESS_DB_HOST, WORDPRESS_DB_USER, WORDPRESS_DB_PASSWORD and WORDPRESS_DB_NAME marked, and WORDPRESS_CONFIG_EXTRA marked as a value evaluated by eval() in wp-config.php. The four database variables and WORDPRESS_CONFIG_EXTRA are all the compose file needs; the other variables are dimmed. Source: hub.docker.com, captured Nov 20, 2026.

5

Configure Caddy for HTTPS

serversudo nano /opt/wordpress/caddy_config/Caddyfile
Caddyfile — nanowp.YOUR_DOMAIN {
    reverse_proxy wordpress:80
}

wordpress:80 is the service name and Apache’s port from the compose file. Caddy requests a Let’s Encrypt certificate on its own, as long as DNS points here and ports 80 and 443 are open (Caddy’s automatic HTTPS docs). Caddy’s reverse_proxy also sets the X-Forwarded-Proto header by default, which is what the image’s wp-config.php reads to switch on HTTPS.

6

Open the firewall and start the stack

serversudo ufw allow 80
sudo ufw allow 443
cd /opt/wordpress
sudo docker compose up -d
sudo docker compose logs -f caddy

Press Ctrl+C to leave the logs once Caddy reports the certificate as obtained. The first start downloads all three images and can take a few minutes.

Only 80 and 443 need ufw rules. Port 8080 stays closed because of the 127.0.0.1 binding in step 4, not because of ufw — Docker’s own install page warns that published container ports skip ufw rules:

Docker’s Ubuntu install page, Firewall limitations: if you use ufw or firewalld, ports you expose with Docker bypass your firewall rules; the second point about iptables is dimmed. A plain Docker port skips ufw, which is why WordPress is published on 127.0.0.1 only. Source: docs.docker.com, captured Nov 20, 2026.

Then open https://wp.YOUR_DOMAIN. The first visit shows the WordPress installer — it asks for the site title and an admin username, password and email, not the database details (those came from the env file). Pick a long admin password and a username that isn’t admin.

If it fails: Caddy logs a challenge error. DNS doesn’t point here yet, or port 80 is blocked in your provider’s network firewall. Fix that, then run sudo docker compose restart caddy.

7

Replace WP-Cron with a real cron job

WordPress normally runs its scheduled tasks — publishing scheduled posts, checking for updates — on page visits, through wp-cron.php. On a quiet site that means tasks run late or never. Step 4 set DISABLE_WP_CRON, so now you tell the server to call wp-cron.php on a timer instead. The WordPress cron docs describe exactly this.

WordPress developer docs, hooking WP-Cron into the system task scheduler: after scheduling the task on your system, WordPress will still run WP-Cron on each page load, so add define(‘DISABLE_WP_CRON’, true) to wp-config.php. The line step 4 passes in through WORDPRESS_CONFIG_EXTRA. Source: developer.wordpress.org, captured Nov 20, 2026.

WORDPRESS CRON a visitor loads a page default behaviour wp-cron.php runs only when someone visits tasks run late or never system cron job every 5 minutes wp-cron.php runs on time, every time tasks run on time
WORDPRESS CRON a visitor loads a page default behaviour wp-cron.php runs only when someone visits · default, unreliable system cron job every 5 minutes wp-cron.php runs on time · fixed, on time

Open the root crontab on the server and add one line:

serversudo crontab -e
file*/5 * * * * curl -s https://wp.YOUR_DOMAIN/wp-cron.php?doing_wp_cron > /dev/null 2>&1

Every 5 minutes the server fetches wp-cron.php, which runs anything overdue. The WordPress docs show the same idea with wget; curl does the job and is already on the server, because Docker’s Ubuntu install steps install it. Five minutes is our pick for a small site; scheduled posts go out at most a few minutes late.

8

Back up the database and wp-content, then test the restore

Everything that is yours lives in two places: the database (wordpress_db volume — posts, pages, settings) and wp-content (inside wordpress_wp — uploads, themes, plugins). Back both up off the server.

Dump the database first. The -T keeps the output plain, and sudo tee writes it into the root-owned backups folder:

servercd /opt/wordpress
sudo mkdir -p backups
sudo docker compose exec -T db sh -c 'mariadb-dump -u root -p"$MARIADB_ROOT_PASSWORD" "$MARIADB_DATABASE"' | sudo tee backups/wordpress-$(date +%F).sql > /dev/null

Then archive the files volume, with the container stopped so nothing is half-written:

serversudo docker compose stop wordpress
sudo docker run --rm -v wordpress_wp:/data:ro -v /opt/wordpress/backups:/backup ubuntu tar czf /backup/wp-data-$(date +%F).tar.gz -C /data .
sudo docker compose start wordpress

Pull both files off the server, from your own computer:

your computerscp 'yourname@YOUR_SERVER_IP:/opt/wordpress/backups/*' .

Keep the passwords from .env with them. Then test the restore, not just the backup: on a fresh server, load the dump back into a new database, extract the archive into the wp_data volume, start the stack and confirm you can log in. A backup you have never restored is a hope, not a backup.

BACKUP ROUTINE DUMP THE DATABASE STOP WP + ARCHIVE FILES COPY IT OFF SERVER TEST THE RESTORE back up the database and wp-content, then prove the restore
BACKUP ROUTINE DUMP THE DATABASE STOP WP + ARCHIVE FILES COPY IT OFF SERVER TEST THE RESTORE back up the database and wp-content, then prove the restore

Key takeaways

  1. To self-host WordPress, run the free wordpress.org software in Docker Compose with MariaDB and Caddy — that’s the .org software, not the WordPress.com hosted service.
  2. The stack is WordPress + MariaDB + Caddy: bind WordPress to 127.0.0.1, let Caddy handle HTTPS, and keep the database on Docker’s internal network.
  3. Replace WordPress’s per-visit cron with a real system cron that calls wp-cron.php every 5 minutes.
  4. Back up both the database and wp-content off the server, and test a restore — not just the backup.
  5. You are the update and security department: patch themes and plugins, lock the login page, and keep UFW and SSH keys tight.

A VPS for this guide

Everything above runs on a VPS with 2 GB of RAM or more. The cheapest 2 GB+ plan at each provider whose prices we read every day, IPv4 included:

Plan · providervCPU · RAM · diskYou payVisit
1 slice
InterServer · New York +2
1 vCPU·2 GB·40 GB$3.00/mo
KVM VPS Special 2 GB
RackNerd · New York +3
2 vCPU·2 GB·35 GB$3.00/mo
VPS nano G11.5s
netcup · Nuremberg
2 vCPU·2 GB·60 GB$3.36/mo
SSD VPS 2
CloudCone · USA
4 vCPU·2 GB·60 GB$3.83/mo
NVMe 2 GB
HostHatch · Amsterdam +15
1 vCPU·2 GB·10 GB$4.00/mo

Prices read Dec 4, 2026. gets that provider's deals on Telegram. Compare every 2 GB plan →

Hardening WordPress on a VPS

The setup above already keeps the database off the internet and WordPress behind HTTPS. Four more habits stop the usual attacks:

  • Update everything, fast. Minor core releases, which carry the security fixes, install on their own by default, and new installs also take major releases automatically (WordPress update docs). Plugins and themes don’t, except for rare critical fixes pushed by the security team. Update them in wp-admin as soon as a release lands, or switch on auto-updates per plugin, and delete plugins you don’t use.
  • Protect the login page. WordPress has no built-in limit on failed logins at wp-login.php, so a public login page attracts password guessing. A long admin password and two-factor authentication are the minimum; a login-limiter plugin stops the brute-force attempts themselves.
  • Turn off XML-RPC if you don’t need it. xmlrpc.php powers the mobile apps and some third-party tools, but it is also a favourite target for password guessing. If nothing you use calls it, disable it with a plugin or block the file in your proxy.
  • Keep the server layer locked. SSH key login only (see our SSH key guide), and UFW allowing just 22, 80 and 443. WordPress is only as safe as the box it runs on.

Common self-hosted WordPress problems

The site redirects to http:// or the admin loop-refreshes.WordPress isn’t seeing HTTPS. Open the site through https://wp.YOUR_DOMAIN (Caddy), not the server IP, and check that both addresses under Settings → General start with https://. If you pasted your own PHP into WORDPRESS_CONFIG_EXTRA, take out anything with $ in it, then sudo docker compose up -d to recreate the container.

“Error establishing a database connection”.WordPress can’t reach MariaDB. Check the WORDPRESS_DB_* values in .env, and that the db container is up with sudo docker compose ps.

Scheduled posts don’t publish on time.DISABLE_WP_CRON is set but the cron job isn’t. Check sudo crontab -l, or run the curl line by hand and look for a response.

Uploads fail with “maximum upload size”.PHP’s default upload limit is small. The image docs say to put a custom .ini file in PHP’s conf.d folder: create /opt/wordpress/uploads.ini with upload_max_filesize = 64M and post_max_size = 64M, add - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini:ro under the WordPress service’s volumes:, and run sudo docker compose up -d.

A plugin update broke the site.Don’t panic. Restore the site from the step 8 backup, or disable the plugin by moving its folder out of wp-content/plugins/ and restarting WordPress.

Questions

What does it mean to have a self-hosted website?

It means you run the website software on a server you control — a VPS you rent, or hardware at home — instead of on a platform that runs it for you. You own the files, database, updates and backups.

Is self-hosted WordPress free?

The WordPress software is free and open source, so the software itself costs nothing. You pay for the VPS and the domain; a 2 GB VPS starts around $2.33 a month in our data.

Is WordPress outdated in 2026?

No. On Nov 24, 2026, W3Techs counted WordPress on 57.3% of the websites whose content management system it can identify — 38.4% of all websites. It is still actively developed: the official Docker image ships WordPress 7.1, with 7.2 in beta.

Is self-hosting legal?

Yes. WordPress is released under the GPLv2 (or later) licence, which lets you run, modify and redistribute it. You are responsible for what you publish, but running the software on your own server is entirely legal.

Do I need to know how to code?

No. The installer is a web form, and the steps above are copy-paste. You do need to be comfortable in a terminal for updates and backups — that’s the part that never goes away.

How much does it cost to self-host WordPress?

A domain plus a small VPS. The three 2 GB-class plans in this guide run $2.33, $3.36 and $3.00 a month in our data, with the terms spelled out above.

How we checked: The steps follow the official WordPress image documentation on Docker Hub (and the image’s own wp-config-docker.php on GitHub), the MariaDB image documentation, Caddy’s reverse proxy and automatic HTTPS docs, Docker’s Ubuntu install page and WordPress’s developer documentation for cron and updates, all read on 2026-11-20; we did not run them on every provider’s image. WordPress’s software requirements, licence and the .com-versus-.org explanation come from wordpress.org; the usage share comes from W3Techs. Plan prices and the billing terms come from our daily reads of provider pages and our checked provider notes. How we check.

Keep reading