Wordpress S3

Recently I wrote a post on Keeping Fat Content Off Your Site, in that post I mentioned the service Amazon S3, today I want to expand on that post and tell you in more detail what S3 is and how you can integrate S3 with your Blog.

What Is S3?

S3 is the acronym of Amazon’s simple storage service. Using this service you can store files on the Amazon infrastructure and access them from your WordPress blog.

But Amazon Sell Books Not IT Infrastructure!

To setup a private CDN for our WordPress site we’ll combine three AWS services: S3, IAM and Cloudfront. S3 (Simple Storage System) is AWS’ free cloud storage solution. First, we’ll create an S3 bucket (AWS’s weird name for a cloud storage folder) which we’ll use to synchronize media content from our WordPress site using a plugin. Amazon S3 is a managed storage service that provides an affordable, performant, and secure method for storing all kinds of data. The interface between WordPress and Amazon S3 is the WP Offload Media Lite plug-in from Delicious Brains.

Yes they are an e-tailer first and foremost, but they have built an absolutely fabulous back end solution for their IT requirement. It is incredibly robust and scalable so that can roll out new functions and products to their vast website quickly and easily.

They knew that were onto a good thing and thought that they though they would sell that as well.

The Amazon web service (AWS) family of products comes directly from what they were doing to host and sell all of their myriad of products. They had to have an incredibly flexible way to expand their capacity quickly and easily. It is these systems that Amazon have packaged up and made available to the wider online community.

What Can You Do With s3

S3 is a storage container, you can host all or part of your WordPress site on S3, The majority of people reading this post will want to host their pillar content on s3. This can be big e-books, videos or other content that you are expecting a lot os people to access. This is what I will concentrate on in this post. If you are interested in hosting your entire sites please check out Amazon EC2 http://aws.amazon.com/ec2/.

Drop It In A Bucket

The individual unit of storage is called a bucket. You create a bucket on your s3 account and upload files to that bucket, these files can then be accessed via a URL like this http://{yourbucket}.s3.amazonaws.com/filename.

You Can Secure Your Files

S3 comes with a number of security features so you can secure your uploaded files and control who can access the information.

Access to your storage space is granted via a public and private key pair. A blog on WordPress is not the place to go into PKI cryptography, but in brief you get two long strings of characters, one public that people use to decrypt your messages, and the other private which you use to encrypt messages, these are used instead of login IDs and passwords.

Using an access control list (ACL) you can set permissions on the file, the permissions are read, write and full control. There are also two other permission levels to allow people to set ACL privileges. Permissions can be set for everyone, authenticated users or the file owner you, via the email address of another s3 user. The acl can be set at a bucket level or on individual files.

Full details of the security model can be seen at http://docs.amazonwebservices.com/AmazonS3/latest/index.html?S3_ACLs.html

ACL & Pre-signed URLs

Another security feature of S3 is a pre-signed URL, using this and an ACL, you can create a link to a secured file with time limited access. This is excellent to provide secure controlled access to your content. Your reader gets a link, that can only be used for a set time, if that link is shared withs. WordPress membership sites owners with premium content I am looking at you here.

Let me paint a scenario, you have a WordPress membership site with premium videos for example, you d’n;t want to share it on YouTube because you want people to pay, then upload it to S3, slap on an ACL so only authenticated users can see the content, then provide a link to that video with a pre-signed URL which last for an hour. Your member views the video but decides to share the info with non-paying members, the link will only be valid for one hour, any attempt to access the link after one hour will return a access denied message. Problem solved.

Cost of Storage

You pay for your storage in three ways:

  1. When you transfer in or upload files to your account
  2. You pay an ongoing storage cost for your files
  3. You pay when people download your stuff

This may seem a bit harsh to be hit three ways, but consider this, the charges are pennies the cost as of November 2009, you pay 0.15 cents for the first 50TB of storage, that is not a typo 50 terra-bytes, you need to write a lot of e-books to fill 50TB see update below. 10 cents per GB to upload files to your buckets and 1 cent per 10,000 gets or downloads of your file. That is not a lot of money for the potential infrastructure you could build.

UPDATE: You pay $ 0.15 per GB for the forst 50TB of storage per month, my mistake thanks for the heads up Markus, still not a bad deal, but not as good as I outlined appologies.

Wordpress

For current pricing see http://aws.amazon.com/s3/#pricing

Tell My Why is it such a Big Deal in 100 words or less

You can store and deliver huge amounts of content securely, robustly, and very cheaply. You can distance yourself from performance problems when delivering content, and not impact other areas of your site streaming fat content. (35 words)

Are there any plugins? You Betcha!

I have used the following plugins in line with S3.

Amazon S3 Plugin For WordPress – http://tantannoodles.com/toolkit/wordpress-s3/

This plugin allows you to upload content directly to your S3 buckets from inside of WordPress. It allows you to host your entire uploads directory on S3 so everything you add to yoru blog be it images, video podcats etc will be hosted and served from Amazon’s site.

Amazon S3 URL Generator – http://codepolice.net/2008/12/08/generate-expiring-urls-for-amazon-s3-via-a-wordpress-plugin/

Now this one comes with a caveat, it is an experimental plugin, the developer clearly states that and I had to re-code it a little to meet my needs, but it dynamically creates a presigned URL link to your content. I am using this on the WordPress Owners Club to secure my screencast videos. If you are happy with a little coding this is an excellent plugin.

Amazon S3 Firefox Organizer – https://addons.mozilla.org/en-US/firefox/addon/3247

Amazon S3 Wordpress Plugin

Whilst not a WordPress plugin, this FireFox plugin is an excellent little tool upload and download files to your buckets, it lets you set ACLs and create new buckets on your account, create test presigned URLs and in fact you can do most things on your S3 storage area with it you would want to, my must have tool for using S3.

Why I am Using S3

When you start adding fat content to your blog, your hosting account will quickly become swamped with requests, your blogs performance will suffer. I wanted to off load this larger content to a more robust platform but did not want the cost of an individual virtual private server. S3 provided this for me.

Computing in the cloud is the way forward for bloggers, very few of us host our own sites on physical boxes we own, we are using hosting providers and their limitations. As big net based companies start providing cloud infrastructure that is cheap and robust I can see many of us moving away from Godaddys and the like. I expect to see Microsoft, Google and the big online boys and girls following Amazon in the future.

Wrap Up

If you are concerned that your latest fat content will go viral and kill your site, check out S3 so your site does not kick the bucket (see what I did there ? What a clever use of the word bucket, our storage unit and the euphemism to die I am soooo funny I am.)

Web administrators transitioning the existing WordPress sites (and image resources) to Amazon S3 have couple of paid plugins to choose from to ease the move to S3. However, most of the WordPress plugins come at a pretty hefty prices, some as high as couple of hundred dollars. The following guide outlines the step by step option that is completely free of charge.

Step by Step Guide:

First of all, login to Amazon S3: https://console.aws.amazon.com/s3/ and create a new bucket for your WordPress images, you can call it whatever you wish, just choose the name that’s available and note that caps are not allowed when naming S3 buckets). So, something like this:

Leave the permissions like this (logging is options, but you may want to know the details of how your images are being accessed):

As far as permissions, leave the reading of images open to everyone:

The bucket review should look like this:

Go to Amazon and get your ‘Access Key ID’ and ‘Secret Access Key’ for the Amazon AWS account in question.

Now, login to your WordPress, then under Plugins, install ‘Amazon Web Services‘ Plugin:

Once installed, activate the plugin and click on the access keys option:

Now you have an option of defining your Amazon S3 access keys in wp-config.php or through the form.

If you want to do this through wp-config.php, simply copy the following snippet into wp-config.php and replace the stars with the keys:

define( ‘DBI_AWS_ACCESS_KEY_ID’, ‘********************’ );
define( ‘DBI_AWS_SECRET_ACCESS_KEY’, ‘****************************************’ );

Otherwise click on ‘store your Access Keys in the database’, there is an option to click here to reveal a form, right at the bottom of the screen:

Enter your Amazon Access Key ID and Secret Access Key:

Now, that the AWS account and plugin is all setup, we’ll need to download and configure another WordPress plugin.

Go to Plugins, Add New and search for ‘WP Offload S3 Lite‘ WordPress plugin, it should look like this:

Once installed and activated, simply go to its settings:

Then select option to ‘Browse Existing Buckets’:

and select the bucket you’ve created earlier, in my case it looked like this:

Once selected, configure the options as follows:

With above setting, all new images uploaded to your WordPress will automatically be moved to Amazon S3, removed from your local server and served from Amazon S3.

If you do not wish the images to be deleted from your local server, turn off the option ‘Remove Files From Server.’

If you also wish to move all of your existing WordPress images to Amazon S3, you can purchase ‘WP Offload S3’ WordPress plugin full version, which offers that option as a paid upgrade.

However, you will also be able to do this for free, if you regenerate your images, which essentially tricks WP Offload S3 Lite into thinking that the existing images are brand new uploads.

To do so, go to Plugins, Add New and search for ‘Regenerate Thumbnails‘ WordPress plugin, it should look like this:

Install and activate it.

Then go to Tools, Regenerate Thumbnails and press the button: ‘Regenerate All Thumbnails’:

All your images will be moved to Amazon S3. Depending on the number of files, it may take a long time to process:

Depending on the upload bandwidth available to your server and the total number of images, all your image resources will be uploaded to Amazon and removed from your local server.

For one of my smaller sites, resizing, and moving 586 images to Amazon S3, took approximately 1,429 seconds, or 2.43 seconds for each image on average. That’s about 40 minutes per 1,000 images:

To test the results, simply right click on any of the images uploaded to your website and you’ll find that its URL points to Amazon S3 now.

Wordpress S3 Plugin

For example, the image stored at this address of your WordPress site:

/wp/wp-content/uploads/2017/03/fast-track-to-mortgage-freedom-w-1.jpg

, will be stored in the following bucket address now:

http://s3.amazonaws.com/wordpress-imgs/wp/wp-content/uploads/2017/03/13002252/fast-track-to-mortgage-freedom-w-1.jpg

At the current prices, 500gb worth of images stored in Amazon S3, would come at the cost of approximately 11.42 USD:

To move your sites images to S3 is not only more economical than hosting them on your dedicated server, where cost of storage is much more expensive, but moving images out of your web server and additional pairing with Amazon CDN, will also make your site much faster to your customers.

Wordpress S3 Uploads

Enjoy!

Wordpress To S3

Facebook Comments