Host a static WordPress website

It doesn’t make any sense, isn’t it? well, let me explain…

This website you are reading now is static, but I use WordPress to write articles, manage all the content, and leverage the vast library of themes.
If you know what WordPress is and how it works, you now are rising your eyebrow. ๐Ÿคจ

Yes, this website is entirely hosted on AWS S3 and you are accessing it securely through Amazon CloudFront.

Why?
Simply because It’s cheaper (and I hate to think that I have an EC2 instance up doing nothing most of the time).

I had a WordPress server running for a year and I used to pay ~ 13 โ‚ฌ/month. Now with S3 + CloudFront, I expect to pay ~ 3 โ‚ฌ/month.

Please note: This configuration only makes sense if you:

  • Donโ€™t need dynamic content on your website right from the beginning (e.g. comments, newsletter, special website sections available only to logged-in users)
  • Publish new content Infrequently
  • Want to use a visual page editor instead of writing HTML or MarkDown
  • Donโ€™t want to spend much time in styling but use templates instead

With that said, let’s dig into some more details…

Basic WordPress architecture (on AWS)

If you want to stick with Amazon’s reference architecture for WordPress, this is what you should deploy.

A little too much for what you and I may need to start with.

If you need a dynamic website, I advise you to read the article “Cost-Effective AWS Architectures for WordPress” by Van Hoang Kha. This is the smallest architecture you can deploy (what I used to utilize).

But if you want to use WordPress and don’t need all the dynamic features (at least not right from the beginning), this is what you could deploy.

The main parts are:

  • Distribution (Route 53, Cloudfront, S3): always online
  • Management (EC2, EBS Lifecycle Manager): runs only when we need to add or modify content on our website.

How it works

Here is a short demo.

In essence, we create an EC2 instance with WordPress installed and configure EBS Lifecycle Manager to take snapshots of it (so we don’t risk losing our Content Management System). After enabling the EC2 instance to write content to an S3 Bucket we can install Simply Static and use it to generate the static version of the website (one-click operation). At this point, we can push with a single command all the contents to the Bucket.

On the other side, we buy a domain for our website (with Route 53 for example) and route the traffic to a new CloudFront distribution that is configured to get all the content from the S3 Bucket. At the same time we attach a certificate to our distribution (it’s not required, but no one likes the “โš ๏ธ Not secure” message near a website’s URL, so why not fix it?).

With that architecture in place:

  • we are able to keep our WordPress instance down and start it only when we need it
  • at the same time keep the website online 24/7
  • make it blistering fast thanks to CloudFront

You can find the CDK template ready to be cloned and deployed in your AWS account on my GitHub repo.

Conclusions

I know that this architecture can be improved and I would love to hear your feedback and ideas about it, so please participate in this Reddit Thread or comment on my youtube video.

If you want to chat about it or about other ideas directly with me, feel free to send me a private message on LinkedIn or Twitter!

Thank you for reading, and have a nice day!

Pages

Platforms

Scroll to Top