Deploying Octopress to Amazon S3
I just submitted a pair of pull requests which add explicit support for Amazon S3 to the awesome Octopress blogging platform. This is something I’ve been meaning to do for ages. There will be a followup post about some less-than-awesome things I discovered about the S3 ecosystem.
Here’s the documentation I submitted along with the (comparitively small) patch.
Amazon Web Services (AWS) is a collection of web services that together make up a cloud computing platform, offered over the Internet by Amazon.com. The most central and well-known of these services are Amazon EC2 and Amazon S3. This page will walk you through setting up a blog on S3.
If you haven’t already, go sign up for an Amazon AWS account right now. It’s very inexpensive and you only pay for what you use.
You will need to install s3cmd
. This is available in most Linux distributions, via Homebrew, or directly from s3tools.org. You’ll need to copy & paste access_key
and secret_key
from the Security Credentials page into s3cmd
’s configuration wizard.
s3cmd --configure # Begin interactive configuration
When finished, your ~/.s3cfg
file should end up looking something like this.
[default]
# ...snip...
access_key = ALRJCALDDZUDEGNSSIPE
secret_key = 9DJWHga1Y+uBAFXntDM1Ujd6FrnnUZb/9dLMOqzn
# ...snip...
S3 is really just a huge, fast, and very reliable, key-value store which happens to be accessible over HTTP. It doesn’t recognize index.html
as being special (or even the concept of directories, really) unless you enable “website hosting.”
Unfortunately, the latest version of s3cmd
doesn’t let you do this yet, so you’ll have to use the AWS Console. Create a bucket having the same name as the fully-qualified domain name of your blog (e.g., blog.example.com
). Open the Properties pane for your bucket, and then the Website tab to turn this on. Make note of the “endpoint”, something like blog.example.com.s3-website-us-east-1.amazonaws.com
. You can use this directly, but most people will create a DNS CNAME pointing to it instead.
In your Rakefile
, set the deploy default to s3 and configure your bucket.
deploy_default = "s3"
s3_bucket = "blog.example.com"
Now if you run
rake deploy # Syncs your blog to S3
in your terminal, your public
directory will be synced to your bucket.