← All templates · Websites and shops
Deploy WordPress in one click
A website and blog builder with themes and plugins
A self-hosted alternative to Wix, Squarespace, and WordPress.com.
What is WordPress?
WordPress is an open-source website builder and blogging platform that people run in place of Wix. Posts and pages are built from blocks in the block editor. With a block theme, the Site Editor reworks the header, the footer and every template from the same blocks, without code. Plugins add what the core leaves out, such as a WooCommerce store. Each user gets a role, from Administrator and Editor down to Contributor, who can write posts but not publish them.
People self-host WordPress for the freedom its GPL license gives: install any theme or plugin, change its code, and keep the files and the database in their own hands. It suits a blog, a portfolio, a company site or a small shop. The catch: the official Docker image cannot send email, so password resets and notifications need an SMTP plugin and a mail service.
This template runs the official WordPress image with MariaDB and adds WP-CLI, WordPress's command line: the wp command is ready in the wordpress service's shell, over SSH or in the panel's web terminal. It runs as www-data, who owns the site's files, so wp plugin install or wp user list need no --allow-root and leave no file root owns.
Hosting WordPress on Pethost
- You sign in to Pethost with a passkey, GitHub or Google. No machine yet? You pick a plan, and the link waits until it is ready.
- New project opens at WordPress, and you click Create project.
- In a minute or two WordPress is live at its own address with HTTPS. Its secrets are made at random, and its data is in the nightly backup.
- It is a project like any other: you or your agent can change it, roll it back or restore it.
Questions about WordPress
Is WordPress free and open source?
Yes. WordPress is free software under the GPL, version 2 or later: you may run it for any purpose, study and change its code, and share copies, changed or not.
What is the difference between WordPress.org and WordPress.com?
Where it is hosted. Both run the same WordPress software: WordPress.org gives it to you to install on hosting you choose, and WordPress.com is a hosted service of Automattic that runs the site for you.
Can I build an online store with WordPress?
Yes, with WooCommerce, a free, open-source plugin. It sells physical goods and digital downloads and takes payments through Stripe, PayPal or Square; subscriptions, bookings and memberships come as paid extensions.
How do I move a WordPress site to a new host?
Export it with Tools > Export, which saves posts, pages, comments, categories, tags and users in one WXR file. Tools > Import > WordPress on the new site reads it and can download the media. Themes and plugins stay behind.
How do I increase the WordPress upload limit in Docker?
Put upload_max_filesize and post_max_size in an .ini file in PHP's conf.d folder: the official image keeps PHP's 2 MB default and has no variable for it. This template already sets both to 64 MB.
How do I use WP-CLI with WordPress in Docker?
The official WordPress image has no WP-CLI, so this template adds it. Open a shell in the wordpress service, over SSH or in the panel's web terminal, and run wp, such as wp plugin list: it runs as www-data against the site's database, with no --allow-root. The image has no MySQL client, so wp db export and wp db import do not run there: mariadb-dump in the db service's shell makes a dump.
How much memory and disk does WordPress need?
WordPress is light: about 200 MB with MariaDB, more with heavy plugins; media uploads are what fill the disk. On Pethost the Starter plan is enough for it, with room for other apps beside it.
WordPress Docker Compose file
The template is this compose.yaml and the variables written into the project’s .env as it is created. Pethost runs the file as it is written.
Containers: wordpress (wordpress:7-apache), db (mariadb:11.8).
Volumes, in the nightly backup: wordpress, db.
services:
wordpress:
image: wordpress:7-apache
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
# PHP's own upload limit is 2 MB, too little for a photo or a theme, and the image has no
# variable for it: the limit is written, then the image's own entrypoint starts as it would.
#
# The image has no WP-CLI either. An image of our own would have to follow each release of
# WordPress's, and one built at the deploy would fail it whenever GitHub does. So the release
# named here is downloaded at the container's start, beside PHP and outside the site's files,
# and kept only if it has the SHA-512 WP-CLI published for it. A restart downloads nothing,
# and a failed download leaves `wp` out until the next start: WordPress starts all the same.
#
# `wp` runs WP-CLI as www-data, who owns the site's files, so that a plugin it installs is
# one WordPress can update, with no --allow-root. runuser keeps the environment, which
# wp-config.php reads the database's address and password from, as a login with `su -`
# would not. WP-CLI keeps its cache in its user's home, /var/www, which is root's: its
# folder there is made www-data's.
entrypoint:
- sh
- -c
- |
printf 'upload_max_filesize = 64M\npost_max_size = 64M\n' > /usr/local/etc/php/conf.d/uploads.ini
phar=/usr/local/lib/wp-cli.phar
sha512=be928f6b8ca1e8dfb9d2f4b75a13aa4aee0896f8a9a0a1c45cd5d2c98605e6172e6d014dda2e27f88c98befc16c040cbb2bd1bfa121510ea5cdf5f6a30fe8832
if ! echo "$$sha512 $$phar" | sha512sum -c --status 2>/dev/null; then
rm -f $$phar /usr/local/bin/wp
curl -fsSL --connect-timeout 10 --max-time 60 -o $$phar.part https://github.com/wp-cli/wp-cli/releases/download/v2.12.0/wp-cli-2.12.0.phar
echo "$$sha512 $$phar.part" | sha512sum -c --status 2>/dev/null && mv $$phar.part $$phar
rm -f $$phar.part
fi
if [ -f $$phar ]; then
printf '%s\n' '#!/bin/sh' \
'[ "$$(id -u)" = 0 ] && exec runuser -u www-data -- "$$0" "$$@"' \
'exec php /usr/local/lib/wp-cli.phar --path=/var/www/html "$$@"' > /usr/local/bin/wp
chmod 755 /usr/local/bin/wp
install -d -o www-data -g www-data /var/www/.wp-cli
else
echo 'WP-CLI 2.12.0 could not be downloaded and checked: wp is left out until the next start' >&2
fi
exec docker-entrypoint.sh apache2-foreground
volumes:
- wordpress:/var/www/html
db:
image: mariadb:11.8
restart: unless-stopped
environment:
MARIADB_DATABASE: wordpress
MARIADB_USER: wordpress
MARIADB_PASSWORD: ${DB_PASSWORD}
MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
volumes:
- db:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 5s
timeout: 5s
retries: 12
start_period: 60s
volumes:
wordpress:
db:
More in Websites and shops
- GhostA publishing platform for blogs and newsletters
- GravA flat-file CMS: a fast website or blog with an admin panel and no database
- JoomlaThe open-source CMS for websites, with several languages, access levels and thousands of extensions
- Spree CommerceAn open-source e-commerce platform: products, orders, payments and a headless API for any storefront