Skip to content

Instantly share code, notes, and snippets.

@Meldiron
Last active February 9, 2025 20:42
Show Gist options
  • Save Meldiron/3cca009bf03ce79d9332996b66c208f2 to your computer and use it in GitHub Desktop.
Save Meldiron/3cca009bf03ce79d9332996b66c208f2 to your computer and use it in GitHub Desktop.
Ubuntu setup for multi-site wordpress hosting
# 1. Install Docker (https://get.docker.com/)
curl -fsSL https://get.docker.com -o install-docker.sh
sudo sh install-docker.sh
# 2. Setup Caddy
mkdir -p caddy
cd caddy
mkdir -p conf
nano conf/Caddyfile
# Start of Caddyfile
mysite.eu {
reverse_proxy 172.17.0.1:8000
}
# End of Caddyfile
nano docker-compose.yml
# Start of docker-compose.yml
services:
caddy:
image: caddy:2.9.1
restart: unless-stopped
cap_add:
- NET_ADMIN
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- $PWD/conf:/etc/caddy
- $PWD/site:/srv
- data:/data
- config:/config
volumes:
data:
config:
# End of docker-compose.yml
docker compose up -d
# To reload Caddy in future
docker compose exec -w /etc/caddy caddy caddy reload
cd ..
# 3. Setup wordpress
mkdir -p site1
cd site1
nano docker-compose.yml
# Start of docker-compose.yml
services:
db:
# We use a mariadb image which supports both amd64 & arm64 architecture
image: mariadb:10.6.4-focal
# If you really want to use MySQL, uncomment the following line
#image: mysql:8.0.27
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=somewordpress
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=wordpress
wp:
ports:
- 8000:80
image: wordpress:6.6.2-php8.3-apache
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=wordpress
- WORDPRESS_DB_NAME=wordpress
volumes:
db:
# End of docker-compose.yml
docker compose up -d
# 4. Connect domain
# Configure A DNS record to point to IP of server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment