Quick Tip for Easily Deploying Octopress Blog on Amazon S3
As I could not find an easy way to deploy my blog on Amazon S3 (using the website hosting feature), I remembered that Octopress being based on Jekyll, I might find some help searching via Google for an integration between Jekyll and Amazon S3.
I found some interesting stuff based on s3cmd.
So here is below a modified Rakefile automating publishing to Amazon S3.
First of all, you need to install s3cmd (at least a 1.0.x version), then you need to configure a few things in Rakefile
.
Start by editing the the deploy_default
variable to be s3
.
Next define a new variable like this s3_bucket = "www.mywebsite.com"
.
Finally add a new task in Rakefile
desc "Deploy website via s3cmd"
task :s3 do
puts "## Deploying website via s3cmd"
ok_failed system("s3cmd sync --acl-public --reduced-redundancy public/* s3://#{s3_bucket}/")
end
When done, run s3cmd --configure
for configuring your AWS credential.
You need a bucket on Amazon S3 for hosting your website. Your bucket name must be your blog URL with the http://
stuff, so if you blog is hosted on http://www.mywebsite.com, simply create a bucket named www.mywebsite.com
:
s3cmd mb www.mywebsite.com
After you have created your bucket, you need to log into the AWS Management Console, select your previously create bucket, then show the Properties panel, switch to the Website tab, click on the Enable checkbox, type in index.html
as your Index Document and finally click Save.
Deployment is now only a matter of running the usual command: rake deploy
.
Now your blog should be available online via the default Amazon S3 website hosting URL, that is http://www.mywebsite.com.s3-website-us-east-1.amazonaws.com for our example. In order to use your own domain name, you need to alter your DNS configuration so that you have a CNAME record defined like this:
www 10800 in CNAME www.jerome-bernard.com.s3-website-us-east-1.amazonaws.com.
This is pretty much it. Don’t forget that changes to your DNS configuration can take up to 48 hours to propagate ;-)