Hosting an Octopress Blog on Amazon S3

Octopress is a framework for blogging based on the static site generator jekyll. In short jekyll takes markdown and turns it into blog style html ready to be served straight away with Apache whilst Octopress dresses it up nicely with HTML5, responsive layout goodness and gives you a bunch of options for code formatting and the like. A perfect little blogging setup for hackers for those of us who typically won’t need all the bells and whistles on our blog I’m sure you’ll agree.

Using Octopress, you’d typically write your posts in markdown and process them locally. You’d then have a number of HTML pages to upload to your web server, which would appear no different than any other blog in terms of functionality.

The most interesting thing that coincincides with the creation of jekyll is that it is now possible to serve static websites straight from Amazon S3, meaning that it isn’t neccessary to have a web server to serve a Octopress blog. I’ve been playing a little and have been able to serve my own octopress blog which you can see over at www.ianwootten.com. Here’s how to do it:

Configure an S3 Bucket to Act as a Website

NB: If you want to use your own domain, then you’re going to need to create an S3 bucket from the AWS Console named the same as your domain (so for me I created a bucket called “www.ianwootten.com”.

To configure your bucket as a website, from the AWS Console, select the new bucket and click “Properties”. Choose the “Website” tab from the box that appears and check “enabled” and set the Index document as “index.html”. Click “Save”. Now move to the “permissions” tab and click “Add bucket policy”. Enter a policy as below, with “www.ianwootten.com” replaced with the name of the bucket you’re using.


{
"Version": "2008-10-17",
"Id": "",
"Statement": [
{
"Sid": "PublicReadForGetBucketObjects",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::www.ianwootten.com/*"
}
]
}

If you’ve opted not to use your own domain, then that’s it for S3. Your new bucket website will be available at a combination of the bucket name and the S3 storage location. In my case, this is http://www.ianwootten.com.s3-website-us-east-1.amazonaws.com/. There’s a list of endpoints on the “website endpoints” page in Amazons S3 website docs.

Configure DNS

If you’re wanting to use your own domain, then you’ll need to visit your domain registraar and edit some DNS entries. In my case, I added a CNAME entry “www” pointing to www.ianwootten.com.s3-website-us-east-1.amazonaws.com. You’ll need to use a tool like wwwizer in order to forward from the root of your domain to the www subdomain. e.g. “ianwootten.com” to “www.ianwootten.com”. To get that working, you’ll also need to modify the @ A record and point it to 174.129.25.170. Read this serverfault post if you’re interested to know why.

For more info on CNAME configuration and S3 see Amazons S3 website docs (Specifically the notes on virtual hosting).

Download Octopress and write some Markdown

Having successfully configured Amazon S3 to host your blog, you need to tackle the age old problem of writing some content for it. This was particularly hard for me, given my lack of knowledge about markdown! You may like to take a look at John Grubers explanation of markdown if you’re suffering like me. The Octopress blogging basics gives a good overview of how your new local blogging workflow will work. Essentially new posts are written in the ./_source/posts folder and when rake generate is executed, your entire websites content is output to the ./public folder. You can also run rake preview in order to preview on a local server.

TO publish your blog, it’s merely a matter of transferring your /public content to the S3 bucket you’ve generated.

Having done all that you’ve now no need to run your own server. You’re still dependent on those that operate at S3, wwwizer and your domain registraar, but you’ve removed your own from the equation. You may be interested in checking out Jerome Bernard’s tip on easily deploying Octopress blogs with s3cmd.

11 comments so far

  1. S3 Browser

    Here is how to enable static website hosting feature using S3 Browser Freeware:
    http://s3browser.com/how-to-host-entire-website-on-amazon-s3.php

  2. Kirti

    Nice Article..
    You can host your Static website directly using Bucket Explorer tool easily..
    http://www.bucketexplorer.com/documentation/amazon-s3–how-to-set-s3-website.html

  3. Hey, thanks for linking to my tip :)

    Actually quite some work has been done since my last post.
    As soon as Octopress’ creator do commit my pull request (you can follow it at https://github.com/imathis/octopress/pull/107
    https://github.com/imathis/octopress/pull/107), it will be way more easy to use as there is no need anymore for s3cmd and a simple rake deploy will do if it you configured properly your AWS credentials.

  4. Nice post, but will you be switching to Octopress for your blog?

  5. Ian

    In time, maybe. For what started out as a personal blog, it’s kind of weird for me to think of moving many of my more personal posts over into an octopress world.

    That said – I do really appreciate it’s simplicity for a technical content. Given that’s what the vast majority of my blog is now I may well end up moving across. I’d be sad to leave wordpress though, I’m a veteran.

  6. Pingback: How to Sync Files to Amazon S3 on Linux |

  7. Pingback: How to Sync Files to Amazon S3 on Linux | Linux Luxury – Linux Administration Resources

  8. I’m interested in doing this but am also interested in how the costs stack up relative to bog standard hosting. Is it cost effective to do this?

    I will have to do the calculations myself but I guess you have to calculate the cost per gigabyte of hosting that you have against the cost of using that much space with Amazon. If they compare favourably, you will always win in the cloud because (for me at least) in two years I have not got even close to my hosting limit. Moreover, given that the static site generated by Jekyll/Octopress would get rid of all WordPress’s PHP cruft, the resulting site would likely be more reliable.

    By the way, I am not a coder. I like Markdown though and Octopress looks as though it lies within the grasp of “interested newbie seeking something different”. Octopress may be reaching an inflection point in terms of its popularity!

  9. Pingback: Embarrassing Comments | mattischro.me

  10. Pingback: The Move Towards Static Websites | Ian Wootten

  11. Pingback: How to Sync Files to Amazon S3 on Linux « Mohan

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>