Hosting your static WordPress site on AWS S3

Colin Duggan
3 min readJan 27, 2022

AWS S3 is a great choice for hosting static WordPress sites. It’s both secure and inexpensive, freeing up time that might otherwise have been spent ensuring plugins, themes, and security procedures are appropriately configured.

The following guide describes one possible approach for generating the static site, using Docker Compose to set up and host the local development environment and the Simply Static WP plugin to export the static site to a zip file.

Prerequisites

  • Docker Engine
  • Docker Compose
  • S3 bucket configured to host a static website (Creation of a CloudFront Distribution and Route53 endpoint are beyond the scope of this article, both would be appropriate as part of a production workload.)

Local development environment

A quick start guide for running WP with Docker Compose exists on docs.docker.com. The sample docker-compose.yml is included below and can be built using the command docker-compose up -d. The local WordPress instance can now be accessed on http://localhost:8000.

Downloading your static files

Static site generation can begin once the site has been fully configured. This includes the selection of the site's theme, installation of required plugins, the addition of site content, and any other customizations required to produce the final result.

1 Navigate to Plugins\Add New\ and search for Simply Static.

2. Once installed, navigate to Simply Static\Settings and ensure the following options are configured for destination URLs and delivery method

3. Update the location for Temporary Files by navigating to Simply Static\Settings\Advanced. (This path will write to our wordpress_data volume)

4. Generate static files by navigating to Simply Static\Generate and clicking the Generate Static Files button

5. Once step 4 is complete, click the link to download the static content. Inspect the contents of the .zip file. It should include the following items

  1. index.html
  2. wp-content/
  3. wp-includes/

Uploading to AWS S3

In this step, we simply upload the site to S3 using the AWS console.

Ensure your bucket is configured for static website hosting. This can be enabled through all the usual AWS paths (REST API, SDK, CLI, CloudFormation). We will be sticking with the console.

  • Click on your S3 bucket. Navigate to the Properties tab. Scroll down to the section titled Static website hosting. Enable and select Host a static website as the hosting type. Update the Index document field with our index.html landing page. Save your changes.

We can now upload the contents of our Zip file (index.html, wp-content, wp-includes) using the Upload option on our bucket landing page.

Our shiny new static WordPress site should now be accessible using the public URL for the site. — This is available under the Properties tab for our bucket under the section Static website hosting.

Future Enhancements

The previous guide acts as an introduction to getting a static WordPress site up and running in AWS. In a follow-up article, I refine this current rudimentary setup and include automation for building and deploying to S3. The S3 bucket is also secured behind a CloudFront distribution, and only accessible through a Route 53 endpoint. If you have any comments or suggestions on how this process could be refined, please leave them in the comments section below.

--

--

Colin Duggan

Tech Lead | AWS Community Builder | AWS Solutions Architect Pro | Passionate about learning | Languages include Java, Go, Typescript, and more recently Rust