Wondering how to configure Docker wordpress letsencrypt? We can help you.
At Bobcares, we offer solutions for every query, big and small, as a part of our Server Management Service.
Let’s take a look at how our Support Team help a customer deal with this query.
How to configure Docker wordpress letsencrypt?
Today, let us see the steps followed by our Support Techs for configuration.
Step1: Install docker and docker-compose
Install Docker
- Firstly, update your existing list of packages:
sudo apt update
- Next, install a few prerequisite packages which let apt use packages over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
- Then, add the GPG key for the official Docker repository to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
- Next, add the Docker repository to APT sources:
sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable”
Next, update the package database with the Docker packages from the newly added repo:
sudo apt update
- Finally, install Docker:
sudo apt install docker-ce
At this point, we should have docker-ce installed on host, and the docker daemon should be running.
Install docker-compose
Replace version number 1.23.2 with the latest version listed on GitHub release page.
# Download the latest version of Docker Compose:
sudocurl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)"-o /usr/local/bin/docker-compose
# Apply executable permissions to the binary:
sudochmod+x /usr/local/bin/docker-compose
Now docker-compose is installed.
Step2: Start WordPress and MySQL
Prepare docker-compose.yml file:
version: ‘3.3’
services:
wordpress:
depends_on:
– mysql
image: wordpress:5.0.2
volumes:
– ./wordpress_files/var/www/html:/var/www/html
expose:
– “80”
restart: always
container_name: wordpress
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD:
db_mysql:
image: mysql:5.7
volumes:
– ./mysql_data/var/lib/mysql:/var/lib/mysql
expose:
– “3306”
restart: always
container_name: wordpress-mysql
environment:
MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD:
This file tells docker-compose to start to containers, one with PHP and WordPress and the other with MySQL.
Each container has a shard mount with local storage, thus data will persist outside the containers and so containers themselves can seen as stateless.
With this configuration, the exposed ports are only accessible from within the docker bridge, but not outside.
This is because we are going to use a reverse proxy server in front of it, and only that server should be exposed to public.
Once configure as above, start containers by running:
sudo
docker-compose up -d
Step3: Run linuxserver/letsencrypt
For free SSL/TLS Certificates, the most popular provider is “Let’s Encrypt”.
It is popular enough that docker images are created and actively maintained.
Here we use image from linuxserver/letsencrypt, which will handle the verification process, and renew the certificate every month.
It also provides an Nginx server out of the box, which can be used as a reverse proxy server for wordpress.
Start Container
Since we only have one container to start, follow the instruction from official documentation and simply run it from terminal with the following command:
sudo docker run -d –network=”wordpress_default”\
–cap-add=NET_ADMIN \
–name=letsencrypt \
-v :/config \
-e PGID= -e PUID= \
-e EMAIL= \
-e URL=bd16s.com \
-e SUBDOMAINS=www \
-e VALIDATION=http \
-p 80:80 -p 443:443 \
-e TZ= \
linuxserver/letsencrypt:196
Here use id <username> to get PGID and PUID, and since we want this container to talk to other containers in the virtual network, we need to specify the network name.
It will take some time to validate the domain and get the certificate for the first time.
Once the container is fully started, it will create the config folder.
Edit Nginx Proxy Configuration
From the config folder we need to tell Nginx to forward requests to wordpress container.
go to config/nginx/site-confs
and edit the default
file.
Configure WordPress
Follow the instruction shown below:
- Firstly, install and activate plugin “SSL Insecure Content Fixer”
- Then, go to Settings >> SSL Insecure Content Fixer settings >> HTTPS detection, and select “HTTP_X_FORWARDED_PROTO”
- Finally, go to Settings >> General Settings, and set both “WordPress Address (URL)” and “Site Address (URL)” to the domain name
Step4: Configure Google Analytics
Add plugin MonsterInsights to WordPress and set the tracking ID.
This tracking ID can also used by Google Search Console to verify the ownership of the website.
[Looking for a solution to another query? We are just a click away.]
Conclusion
To sum up, our skilled Support Engineers at Bobcares demonstrated how to configure Docker wordpress letsencrypt
0 Comments