Files
wordpress/README.md
2025-06-24 14:01:09 +00:00

9.4 KiB

Screenshot

Screenshot

Screenshot

Screenshot


How to efficiently install, host, and maintain lightning fast Wordpress websites inside Docker Desktop on Windows 11



Navigation



Prerequisite

  • If you are using Cloudflare to host your domain, you NEED to make sure that it's SSL/TLS encryption mode is set to 'Full (strict)'. By default, domains are set to 'Flexible' and you'll get thrown in an infinite loop when you try and go to your website while using a reverse proxy.

Screenshot

  • For these instructions we'll be using the example domain called 'website.com' and will be changing names and code to match it accordingly, like this 'wp-website-com'.

  • For very nice organization, I recommend keeping the ' wp- ' part at the beginning of the naming scheme so you can easily filter out containers and find what you're looking for very quickly and neatly.

  • The password to extract all of the tutorial files from the zip file is: JHammaH

  • Create a folder called ' wordpress ' in an easy to find directory like: ' c:/docker/wordpress '

  • Extract the contents of the downloaded zip file to inside the new ' wordpress ' folder. You will see three files. A .bat file, a dockerfile, and a folder called ' wp-new-site '

Screenshot



Creating a Custom Network

  • Before you do anything else, you'll need to create a custom network specifically for your Wordpress sites so you don't run out of IP's which can confuse docker and cause issues with reverse proxies.

  • Conveniently I made a simple batch file called 'create-docker-wordpress-network.bat' that all you need to do is double-click.

  • It will create the network range 10.64.0.0 within Docker and then delete itself since you only need to run it once.

Screenshot


Screenshot

  • If you want to use a different network range instead of 10.64.0.0, you can right click on the batch file and change the range to whatever you want. Then save the bat file and run it.


Folder Organization

  • Now you'll need to organize the folder names, which is very important.

  • Copy the ' wp-new-site ' folder and paste it in the same directory and it should create a new folder called ' wp-new-site - Copy '. This will leave the ' wp-new-site ' folder untouched so it can remain a template that you can copy/paste as many times as you want for any new site you want to launch.

  • Rename the new folder you just created, ' wp-new-site - Copy ', to match your specific domain. Ex. ' wp-website-com '. You're keeping the 'wp-' part for easy filtering. You're changing the word 'new' to whatever your domain is. Then you're changing the word 'site' to whatever your domain extention is.

  • So here are a couple of examples:

    • For 'jhammah.com', you would change 'wp-new-site' to 'wp-jhammah-com'
    • For 'takedownthe.gov', you would change 'wp-new-site' to 'wp-takedownthe-gov'
    • For 'dronework.pro', you would change 'wp-new-site' to 'wp-dronework-pro'
  • For this tutorial, I'll be creating a site for the domain I own, scrapyardplays.com, which means I'll change 'wp-new-site' to 'wp-scrapyardplays-com'

Screenshot



Configuring .env file

  • This is the .env file. Here you will want to enter your cloudflare API token as well as the email address you log into cloudflare with. This .env file will create variables that you can reference in your Caddyfile.

Screenshot



Configuring docker-compose.yml file

  • Configuring docker-compose.yml file
code

Screenshot


Screenshot


Screenshot


Screenshot


Screenshot


Screenshot



Execute and Test

  • Execute and Test
docker-compose up -d

Screenshot


Screenshot


Screenshot



Reverse Proxy Steps

  • This is the Caddyfile. This file tells Caddy what and how to do things.

Screenshot



wp-config.php configuration

wp-config.php configuration

// Change the URL to match your actual domain address. Example for ' website.com '
// If you have a reverse proxy handling your SSL, make sure to use ' https:// ' instead of ' http:// '
define('WP_HOME', 'http://website.com');
define('WP_SITEURL', 'http://website.com');

// Replace REDIS_HOST with the name of your new site's Redis docker container. Example ' website-com-redis '
define('WP_REDIS_HOST', 'wp-new-site-redis'); 

// Don't make any changes to the REDIS_PORT
define('WP_REDIS_PORT', 6379);

// Change the prefix from ' new-site ' to match your domain. Example ' website-com '
define('WP_REDIS_PREFIX', 'wp-new-site');

// Change the database number to match what's in your /yml file. If this is your first site, you can
// choose ' 1 ' . If this is your second site, choose ' 2 ', etc. Make sure it matches your /yml file!
define('WP_REDIS_DATABASE', 0); // 0-15

// Specifies reasonable timeouts. No need to change this.
define('WP_REDIS_TIMEOUT', 1);
define('WP_REDIS_READ_TIMEOUT', 1);


Caddyfile configuration

wp-config.php configuration

docker-compose up -d


Support the channel so I can make more tutorials!

If this tutorial helped you out, feel free to buy me a coffee!