Are you trying to Deploy Multiple WordPress Applications On Ubuntu ?
This guide is for you.
Docker is one of the most popular methods used to save, set up and share server environments using containers.
Containers allow to package up any application with all parts of it such as libraries and other dependencies and deploy it as one package.
Docker is designed in such a way to make it easier to create, deploy, and run applications with the help of containers.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to deploy multiple WordPress applications on Ubuntu servers.
In this context, we shall look into the steps to deploy multiple WordPress Apps as a part of our Server Management Services.
How to Deploy Multiple WordPress Applications On Ubuntu ?
Here, we will be using the Docker Linux Container Engine to deploy multiple WordPress applications on Ubuntu. Docker uses containers to deploy applications in a hassle-free manner.
We will be creating WordPress installed Docker images, which will allow us to run another WordPress site on any VPS, by a single command using Docker.
Installing Docker on Ubuntu
1. We can use the following command to update the droplet and ensure aufs support is available.
$ sudo apt-get update
$ sudo apt-get -y upgrade
$ sudo apt-get install linux-image-extra-`uname -r`
2. Add the Docker repository key to apt-key for package verification with the command below:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
3. Next we can add the Docker repository to sources
$ sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\
4. Now we will update the repository first, with the following command:
$ sudo apt-get update
5. Finally, we will download and install Docker with the following command:
$ sudo apt-get install lxc-docker git
6. To enable forwarding with UFW we need to edit the UFW configuration:
$ sudo nano /etc/default/ufw
7. Save and exit the configuration file.
8. Then reload UFW with the following command:
$ sudo ufw reload
9. To allow remote connections for using the docker daemon remotely we need to allow the default port of Docker which is 4243.
$ sudo ufw allow 4243/tcp
Some basic commands used for Docker
1. We can run the docker daemon with the following command:
$ sudo docker -d &
2. Client usage:
sudo docker [option] [command] [arguments]
It must be kept in mind that Docker requires sudo privileges to work as it uses sockets owned by root.
We can get a full list of all available commands by simply calling the client with the following command:
How to create WordPress Containers ?
We will be using the out-of-the-box WordPress image ‘tutum/wordpress’.
In order to create containers from this image, we need to pull (download) it first using the following command:
$ docker pull tutum/wordpress
Once the image is ready, with a single command we can create dockerized WordPress instances.
1. To Create a Publicly Accessible WordPress Container
Run the following command to create a container that is reachable from the outside on a port we specify (e.g. 80):
$ docker run -p 80:80 tutum/wordpress
This command helps to create a WordPress instance that will accept connections from outside on the default HTTP port 80.
2. To Create a Locally Accessible WordPress Container
Run the following command to create a locally accessible container.
$ docker run -p 127.0.0.1::80 tutum/wordpress
Now Docker will create a container and provide its ID and then dynamically allocate a port.
We can find out which port the container is using with the port command given below:
docker port [container ID] [private port number]
$ docker port 9af15d56fdf8a587 80
From the output, we can see that the container is accessible only on the localhost on port 49156.
We can use this address to redirect connections from a reverse-proxy using the following command:
docker run -p 127.0.0.1:[local port]:80 tutum/wordpress
$ docker run -p 127.0.0.1:9091:80 tutum/wordpress
Now the WordPress instance is locally accessible at port 9091.