Hosting my WordPress blog entirely on Amazon S3

Recently, I started going over my monthly bills to see if there was an easy way to cutdown on expenses. One entry that stuck out like a sore thumb was the $60 a month I spend (or should I say, spent) for a VM on EC2. I’ve used this VM for educational projects, hackathons, and testing things in a cloud environment. But none of these uses justified having a continuously running VM. With one exception: my blog is also hosted on this VM, and just shutting down my EC2 instance would have meant losing the blog. So I had to migrate the blog somewhere. Ever since I saw Werner Vogel’s post on how he moved his blog over to Amazon’s S3 service, I’ve been meaning to try that out. However, I wanted to keep using WordPress to edit my blog. I had an idea on how to do this and yesterday I finally had time to do it!

S3 stands for Simple Storage Service. It is a cheap, durable web service offered as part of Amazon AWS. Since Feb 2011, they’ve added the ability to hosts static web sites using an S3 bucket. There are two caveats that come with this: the site is static, and you can’t officially point your naked domain at the S3 service. Dealing with the second problem isn’t that bad and has several solutions. I use GoDaddy for my nameservers, and I simply forwarded my naked domain (slowping.com) to the www.slowping.com. Of course, I modified my www CNAME record to point at my S3 provided “website endpoint”.

All that is left is to resolve the fact that S3 can only host static files but I want to continue to use WordPress to edit my blog. The idea I had centered around having a local VM that mirrored my existing WordPress installation. I then proceeded to edit the hosts file on my home machine(s) whenever I wanted to access the WordPress blog on my local VM. The edit is very simple – I just add my domain name and the IP of the local VM. This makes editing my blog via a web browser very simple. Whenever I want to see the “actual” static blog site on S3, I just undo the hosts file modification. Simple as that!

Did I forget anything? Oh yes … the very important part of converting the dynamic WordPress site into a static one. I performed all these steps on the WordPress installation on my local VM. First, I disabled all the existing plugins (I didn’t have many and this probably made my life easier). I then installed/setup Disqus for commenting and Statcounter tracking hits. Both were fairly easy to do. I tried exporting the comments in my old WordPress system to Disqus, but that didn’t work out for me. I didn’t get any error messages – rather the Disqus system says it takes them 24 hours to process exports. If I get time, I’ll try to debug this further. Otherwise, goodbye old comments :’( Once I had the plugins sorted out, I ran Ammon Shepherd’s awesome “wpstatic” script to create a folder with a static version of my blog. In fact, I wrote a small script that called Ammon’s script first, and then called the “s3cmd” tool to upload the static files into S3.

The overall experience wasn’t that painful. Two big advantages I will get from hosting the blog on S3 are lowered cost and good scalability. If any of my future posts get on HN, it’ll be a good test to see if the new setup holds up under load. In terms of cons, I need to backup my local VM periodically. Also, the hosts file technique I mentioned works well when I want to edit my blog at home. Right now, I have no way to edit the WordPress blog when I am away from home. A few things don’t work correctly yet (e.g. the search box in the blog header, broke my old permalink structure). I’ll continue to iterate and improve.

References:

1) No Server Required – Jekyll & Amazon S3

2) Host Your Static Website on Amazon S3

3) Converting WordPress to static HTML

  • barryhunter

    Why not turn the search box into using
    http://www.google.com/cse/ – that way you outsource the searching to Google. And can easily be hosted in a static html file – as its JS powered.

  • Jon

    How much are you spending now after moving your blog?

    • iqbalmohomed

      Since I only completed the transfer yesterday, I can’t say for sure. I’m anticipating about $1 a month now. Amazon charges for both data storage and HTTP requests (GET requests are cheaper than PUTs), but this is much much cheaper than paying for a VM.

  • Gonewest

    Why don’t you put the vm you created for editing back in EC2 and launch it when needed?

  • http://blog.smarx.com/ Steve Marx

    If you would prefer using a folder in Dropbox versus uploading with s3cmd, consider Site44 (www.site44.com), my startup.

    • iqbalmohomed

      Thanks for the pointer Steve. I checked out the video on your site and Dropbox integration seems seamless!

    • http://ahmetalpbalkan.com/ Ahmet Alp Balkan

      This is really cool.

    • spindritf

      Really cool, and you only request access to a single Dropbox folder

      “This app will create a folder named site44 in your Dropbox. The app will only have access to this folder.”

      which is nice of you, not many app authors bother.

      • http://blog.smarx.com/ Steve Marx

        Thanks!

  • http://twitter.com/vinitcool76 vinit kumar

    Considering that you are using it just for blogging, why not use something like jekyll ? why take so much trouble?

  • http://www.desinle.com/ Desinle

    you might as well get on linode wagon, much cheaper than amazon.. better disk i/o rates than amazon..when you would want to scale, it is less costlier than amazon..