wordpress

This project has been replaced by Hexo
If you’re interested, see my latest post on using the site generator paired with markdown to create a more portable environment.
Hexo Documentation

WordPress

WordPress is a Content Management System (CMS) that is widely known for its flexibility and customization utilizing a basic blog structure of Pages and Posts. Using these two basic formats we can define the foundation of our website or blog and then build out posts and related content from there as needed. WordPress is open source, and is controlled through PHP statements and functions within our website or theme. Most users never see the raw HTML, PHP, or CSS simply because there is a wide range of themes available for free and purchase to suit most needs. If you plan to heavily customize your domain, you will likely need to dive into the code or have someone tweak it for you. In this way, the pre-built themes offered on WordPress provide opportunity to learn theme development.

Plugins

WordPress also offers a wide range of official and third-party plugins to enhance your experience with the CMS. This benefits users heavily when the need for a custom interface or feature within WordPress is present. Most of the time, there is a plugin available to suit your needs – and if there isn’t, you may want to reconsider why you need the feature at all and take a different approach.

Apps

WordPress offers a mobile app capable of populating a news feed of followed blogs, and posting or editing content on your website on the go. This has proven to be a useful feature when out and about and realizing typos or grammar mistakes, they can be corrected within minutes from any smart phone or tablet. Backing up WordPress is proven to be as simple as backing up a database and zipping the appropriate folder within your web server’s root directory.

WordPress Repository

Docker

If you’re interested in using this yourself, be sure to check out the Official Wordpress Docker Image on DockerHub.

I chose to use Docker Compose to create the service in an organized configuration file opposed to running docker commands to start and connect Docker images. I heavily customized my configuration to my needs, binding custom volumes and scrambling ports where needed for security reasons. It is possible to practically copy the default docker-compose.yml on the official WordPress Docker Hub page, and spin up a container in a few minutes for proof of concept. You should never use default passwords or users given in any example docker-compose.yml file.

Once the container is running, you’ll need to configure your host’s web server to pass traffic to the container appropriately. To do this, I paired some basic DNS settings, NGINX, and Let’s Encrypt to terminate SSL on the box’s default web server and then pass the local traffic to the container where it can be handled internally and then encrypted on its way back out to the user for safe decryption on their end.

Snippets

See the snippets below for a basic nginx.conf and docker-compose.yml to spin up your own WordPress, after the necessary modifications are made to the configs, of course.

docker-compose.yml

Below, we have a simple docker-compose.yml for defining WordPress services -

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
version: '3.3'

services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress

wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}

Its important to note above that the volumes we define carry the syntax local:container when defining the path to be mounted, and we don’t need to initialize any directories / configurations in general. When the container starts the first time, directories and files will be created and any volumes defined in the docker-compose.yml used to create the service will be mounted so that the files on the container are available locally on the host. This is a useful tool to help ease the task of automating or scheduling backups and also makes the configurations on the container easier to modify using our local settings and packages.

nginx.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# A simple nginx.conf showing how to pass traffic to a docker container
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events { }

http {
include mime.types;

# Redirect root domains
server {
listen 80;
server_name domain.com www.domain.com;
return 301 https://www.domain.com$request_uri;

}


# SSL - domain.com
server {
server_name domain.com www.domain.com;
server_tokens off;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

# Pass to container
location / {
include proxy_params;
proxy_pass http://localhost:1234/;
}

}

}