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.