During the process of setting up this site, I came to the conclusion that all the available hosting solutions don’t fit my needs. Setting up WordPress and getting it right the first time, is out of reach for many among us. So what do you do?
Looking for Solutions!
Over the years I was hosting multiple sites with different demands in traffic and size. During that process I came to the conclusion that the setup, of each of those sites, was a pain and maintenance more or less impossible. Since I came in contact with hosting the first time, I’ve moved from apache1 to apache2 to IIS to nginx as web daemon. The php execution engine has been updated since then multiple times.
Every time a component needed an upgrade you faced almost a new setup. The process of backup and restore was always tricky and using your own scripts to setup new vhosts where required. After some research I’ve discovered Automated Nginx Reverse Proxy for Docker by Jason Wilder and that led to some research and to the setup you can find in this post.
What else do we have to consider?
The preferred solution needs to be scale-able and distribute-able. Eventually a new player appeared on the software market that allows exactly to solve this.
Lets say hello to docker! Whale, whale!
What is docker?
Docker is an application container system and allows to prepare and configure applications for different environments. To cover docker is a complete different topic and will not be part of this post. But to get you started, just follow one of the guides at the docker site. When you want to scale and distribute have a look at docker swarm.
Get docker-compose ready!
docker-compose is required to start the different containers and setup networks in automated ways. So install docker-compose according to this guide and read on when you’re ready.
What are we going to do now?
Lets think about our infrastructure for a moment. To host our website in a scale able way we need to have multiple components up and running. For now, we settle with one nginx front end server to be easily able to create new vhosts. We employ one Varnish daemon in front of 2 nginx back end servers. Since nginx is only able to serve static content, we need to add a way to integrate PHP into our setup. To get us started we set up two fpm hosts. Since setting up a SQL cluster is out of scope for the moment, we use a single MariaDB host. Memcached1 is a memcached instance that can be utilized by the WordPress installation.
Now that we have our target architecture ready, we can think about how to handle the setup and how we’re still able to scale the instance out.
Let’s create a compose file!
To make it easy to run our site and start the whole environment with ease, we make use of docker-compose. Take a look at the source code of our docker-compose file. We have a closer look at the different things in a bit.
As you can see, we create multiple nodes of different types. For more details on the different images look at my docker-hub profile. The nodes map their required volumes, for example the root volume for our site is mapped to “./.data/test.windegger.wtf/storage”. Depending on your docker setup you might need to adjust some volumes, drivers or networks.
The WordPress container!
The WordPress container is the heart of the installation, it is based on the official WordPress Dockerfile, but modified to use PHP 7. Since it’s using PHP 7 as base, it required some minor adjustments to the original file. For more information about the container take a look at the Hubpage.
After you start the composed environment using “docker-compose up”, you have your new and fresh WordPress installation up and running.
What comes next?
I continue to do research on different topics and cover my findings in my blog. I cover the different topics I’m faced with in my daily life. Prepare for some devops and other development updates.
You’re still reading, so you’ve not found what you came for. You need a trusted professional to handle your site in a managed manner? Don’t hesitate, use the contact form or leave a comment. You will receive a reply shortly.
This post is also available in: German