Ghost Blogging Platform is the newest and coolest open source blogging platform out there. It's a light alternative to Wordpress and a more customizable version of Tumblr. It's got an awesome markdown editor, and the right amount of features.

Amazon Simple Storage Service (Amazon S3) is a great, cost-effective object storage service. Ghost and S3 are a perfect combination and the best way to store images and other assets for your blog or website.

This post is designed to help you setup S3 with your new Ghost Blog.

Setting up Ghost

I have setup Ghost in plenty of different places, from Heroku to Openshift. Both which are fine solutions, but I would say that Digital Oceans is the easiest and most hassle free. For $5 a month you can have your blog up and running.

Here is a $10 Digital Oceans credit!

Once you have your account setup with digital oceans, follow this guide to get ghost up and going:

https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-ghost-application

Setting up S3

Setting up the Bucket

Amazon free tier comes with 5GB of free S3 storage for 12months. This should cover most people. Then its around 23c a GB a month going forward.

  • First, create a bucket in your region of choice.
  • Once you have created your bucket, click on the bucket and then go to properties
  • open permissions, then Edit bucket policy
  • you want your policies to look something like this:
{
  "Statement": [
    {
      "Action": "s3:GetObject",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*",
      "Sid": "AllowPublicRead"
    }
  ],
  "Version": "2008-10-17"
}

obviously replace YOUR_BUCKET_NAME

This is a good time to test the public access of the files. Upload and file and grab its public address and open it in an incognito tab to verify correct settings.

Setting up the user

Head over to https://console.aws.amazon.com/iam/
- This is where create a user with some credentials for the bucket we have just created. Give this user Programmatic Access only.
- Attach existing policy directly
- AmazonS3FullAccess
- Create the User, then copy down the Access key ID and the Secret access key

Integrating S3 and Ghost

Ghost is located at /var/www/ghost in the DigitalOceans droplet

  • First we need to install the ghost-storage-adapter-s3 package, install and follow instructions. Mainly I choose this as it was simple to use, and most recently updated.

  • Next we need to edit the config.js file (in the ghost root)

  • Add the 'storage' key to 'production' key.
storage: {  
  active: 's3',
  s3: {
    accessKeyId: 'YOUR_ACCESS_KEY_ID',
    assetHost: 'YOUR_OPTIONAL_CDN_URL',
    bucket: 'YOUR_BUCKET_NAME',
    pathPrefix: 'YOUR_OPTIONAL_BUCKET_SUBDIRECTORY',
    region: 'YOUR_REGION_SLUG',
    secretAccessKey: 'YOUR_SECRET_ACCESS_KEY'
  }
}

That it, you're all done. service ghost reboot!


Related:
Oscar-Ghost Free Ghost Theme