1 of 9

Installing WordPress on Amazon EC2 using Docker Compose

Tan Lai Chian Alan

18 June 2020

1

2 of 9

Task

Provision a WordPress instance on a AWS Ubuntu VM (Amazon EC2) with necessary monitoring services and tweaks

Assumption: This is a standalone application with all software installed on the same instance

2

3 of 9

WordPress on AWS

There are three main ways to host your own WordPress website on AWS according to the best practices:

  1. Amazon Lightsail (Recommended)
  2. Amazon Elastic Compute Cloud (Amazon EC2)
  3. AWS Marketplace

3

4 of 9

Hosting WordPress on AWS

There are three main ways to host your own WordPress website on AWS according to the best practices:

  • Amazon Lightsail (Recommended)
  • Amazon Elastic Compute Cloud (Amazon EC2)
  • AWS Marketplace

4

5 of 9

Installing WordPress

There are also different ways to install WordPress on a machine (non-exhaustive):

  1. Manually set up WordPress with LAMP stack by installing softwares individually
  2. Using containers (e.g. Docker and Docker compose)
  3. Using infrastructure as code tools (e.g. Terraform, Ansible)

5

6 of 9

Installing WordPress

There are also different ways to install WordPress on a machine (non-exhaustive):

  • Manually set up WordPress with LAMP stack by installing softwares individually
  • Using containers (e.g. Docker and Docker compose)
  • Using infrastructure as code tools (e.g. Terraform, Ansible)

6

7 of 9

Docker Architecture

7

8 of 9

Monitoring

  1. Prometheus (alerts, graphs, queries)
    1. Targets: prometheus, node_exporter, mysqld_exporter, cadvisor
    2. Alerts: Instance down, high storage load
  2. Grafana (Visualisation)
    • Data source: Prometheus
    • Dashboards:
      1. Docker and system monitoring (893)
      2. MySQL Overview (7362)
      3. Node Exporter Full (1860)

8

9 of 9

CICD (Proposed)

9

Build

Release

Production

  • WordPress
  • Mysql db
  • Prometheus
  • Grafana
  • ...
  • build, tag and push docker images to GitLab container registry
  • deploy and run containers
  • integration test

CI

CD

SCM

Current:

  1. SSH into AWS EC2 instance
  2. Install Docker and Docker Compose (one-time installation)
  3. Setup environment variables (db username and password)
  4. Clone git repository to instance (single command)
  5. Run containers using Docker Compose (single command)