Running WordPress on Amazon AWS – For Free!
As some of you may have noticed, I have updated my blog a while ago. The previous version ran on some custom Go code on top of Google AppEngine. It ran fine, it was free, but because it was some custom piece of code, it was very basic. For instance, there was no way to upload images yet and I didn’t feel like implementing it.
So what platform to run on? I could set up a Drupal site on Acquia Cloud for free, but where’s the fun in that? Let’s check out WordPress. The free version on wordpress.com is really limited though and the entry level already kills my wallet at $99/year. So what else?
My job at Acquia involves a lot of AWS related things, so I already know quite a bit about it. But we can always learn more! And they have a nice free tier! Let’s do it!
A decent number of hours later, I had a proper WordPress site up and running. It has all features you could wish for. I have access to the code, can install custom modules and themes. And it’s quite performant, even on a free-tier m2.micro instance, and really scalable. So how did I do it? By making the frontend instance completely stateless.
- The WordPress codebase is packaged in an archive on s3. When a new instance is launched by cloudformation, the archive is automatically fetched and extracted in the appropriate location. The frontend instance is also managed by an autoscaling group. When certain cpu or memory thresholds are reached, a new instance will be launched with the same WordPress archive and the load will be spread across all instances using an ELB.
- The database is hosted on micro RDS mysql instance. RDS automatically backs up the database every day and I don’t have to care about mysql updates. I don’t have to care about a database when the frontend instance gets killed.
- Uploaded media are hosted on s3 using the amazon-s3-and-cloudfront plugin, so nothing gets lost when an instance gets terminated. And in case there are multiple frontend instances, they will all have access to all media.
- Static files in wp-content and wp-includes are served by CloudFront using the wp-super-cache plugin. This same plugin also caches the html for anonymous pages.
There you have it: a highly-scalable, highly-customizable WordPress site, for free. Do you want to give it a try? I just made the CloudFormation template (largely based on an AWS example) available at github.com/blackskad/wp-cloudformation
Do you have any recommendations to improve my setup? I would love to hear your suggestions in the comments!
Ps. Ok, i lied, it’s not totally free. I pay Amazon $0.62 a month for Route53. And when you go over the free quota, you’ll also pay something. But for a tiny personal site, it’s really damn close to $0, right?