Despite all its plugins, WordPress has the option to create a static site. This removes all of the security vulnerabilities so instead of deploying WordPress, you’re only deploying the HTML that it generates.
In this series, we’ll go through how to convert WordPress to static files and host them in AWS S3, a secure channel of storing files. To go live with your site on a custom domain, you’ll connect your S3 bucket to Cloudflare, a DNS service which also offers many security features.
To start your WordPress, all you need is a Docker container, which is what we’ll focus on in the first part of this series.
Part 1 – Building a WordPress in Docker
Part 2 – Downloading Your Static WordPress and Deploying to AWS S3
Part 3 – Connecting Your S3 Bucket to Cloudflare
Building a WordPress in Docker
- Create an empty project directory.
- Change into that directory.
- Create a file called docker-compose.yml with the following contents:
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: - "80:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress volumes: db_data:
- In your project directory, run
docker-compose up -d.
- At some point, your WordPress will be accessible at localhost.
- Go to localhost/wp-admin to start setting up your WordPress.
- Note: To shut down your docker container run docker-compose down --volumes.
- At this point, you’re ready to make changes to your website.
Come back tomorrow to learn how to statically deploy your WordPress to AWS.