How To Set Up Amazon S3 WordPress Site – AWS S3 Tutorial

Avatar

Bart Keating

1 comments

2019 February 11th at 3:50

amazon s3 wordpress

Integrating Amazon S3 storage into your WordPress is a great thing to do for high-traffic or multimedia-heavy sites as you can use it to reduce the stress on your server by offloading media content.

However, Amazon S3 WordPress sites can't be created in a single click like your everyday WordPress website.

So, in this AWS S3 tutorial, I'll walk you a simple process of setting everything up. Here is how to make an Amazon S3 WordPress site:

  • Step 1 - Set up a WordPress site
  • Step 2 - Start an Amazon services account
  • Step 3 - Create an Amazon S3 bucket
  • Step 4 - Make your S3 bucket public
  • Step 5 - Include an IAM user policy
  • Step 6 - Edit your WordPress wpconfig.php file
  • Step 7 - Choose a WordPress S3 plugin
  • Step 8 - Install and configure your S3 plugin

1. Set Up a WordPress Site

The first step to hosting WordPress on Amazon S3 is to create a WordPress site with a different provider. I won't go into detail here as the chances are you already have a site set up. If you don't, check out my selection of the best WordPress hosting providers. The option used in this guide is Hostinger.

Why can't you simply install WordPress directly on your Amazon S3 storage system?

Because AWS uses an object storage system and WordPress can only be installed on traditional file systems, such as the ones offered by hosting providers.

Amazon S3 WordPress Hostinger

2. Start an Amazon Web Services Account

Once the WordPress site is online, it's time to open an Amazon Web Services (AWS) account. 5GB of AWS storage is completely free for the first year of your membership.

Signing up only takes a minute. Just sign up on Amazon, input your information and then hit 'Continue'.

Amazon S3 WordPress AWS Sign Up

The next screen will ask you for some contact information. Fill it in, highlight the final checkbox and then press 'Create Account and Continue'.

Amazon S3 WordPress Create Account

Next, you'll have to provide payment information and verify your phone number.

 These steps just confirm your identity; you won't be charged!

Once you've done that, you'll be prompted to sign into your new AWS account using the credentials you just created.

You should now be redirected to the AWS Management Console homepage.

Amazon S3 WordPress AWS Homepage

3. Create an Amazon S3 Bucket

The next step is to create the storage resource, which AWS calls a 'bucket', that will be linked to your WordPress site. As soon as you're signed into AWS, head over to the S3 section.

Do that either by opening this link or clicking on 'Services' and selecting 'S3':

Amazon S3 WordPress Open S3

On the S3 homepage, you'll see an 'S3 buckets' section. Click on the 'Create bucket' icon:

Amazon S3 WordPress Create Bucket

In the window that pops up, name your bucket and choose the region you want your data to be hosted in. Amazon has data centers all around the world, so opt for one nearest to your site's target audience.

After that, simply click 'Create'.

Amazon S3 WordPress Bucket Setup

4. Make Your S3 Bucket Public

To link your bucket with your WordPress site, it needs to be publicly accessible. Don't worry about privacy too much here, as your bucket will just contain media that would be public via your WordPress site anyway.

To make your bucket public, we need to add a 'bucket policy'. S3 will now take you back to your list of buckets: begin by clicking on your bucket's name in the bucket list.

Amazon S3 WordPress Open Bucket

Before you can create a public access policy, you need to turn off AWS's automatic public access block.

In the 'Permissions' zone, select 'Public access settings' and untick the two bottom boxes to de-activate AWS's automatic filter which is designed to stop you from making your bucket public.

Then, hit 'Save'.

Amazon S3 WordPress Block Policies

Next, in the 'Permissions' tab, click 'Bucket Policy'.

Amazon S3 WordPress Create Bucket Policy

This will open up a blank JSON editor. JSON is a JavaScript based coding language, but don't panic, as you don't need to know any coding to follow this guide.

Just copy and paste the code below into the editor.

Make sure you replace 'INSERTBUCKETNAMEHERE' with your actual bucket name!

{    "Version": "2008-10-17",

    "Statement": [
        {
            "Sid": "AllowPublicRead",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::INSERTBUCKETNAMEHERE/*"
        }
    ]
}

If the editor now looks like the screen below, click 'Save'.

Amazon S3 WordPress Code

When you return to the bucket list, you can verify if the policy worked correctly by checking if a 'Public' tag has been added to your bucket.

Amazon S3 WordPress Public

5. Include an IAM User Policy

You now have to create an IAM user policy to let WordPress edit your bucket.

Pay attention here, that's the toughest step!

Start creating the IAM policy by entering the IAM area of your AWS dashboard and clicking 'Add user' in the 'Users' section.

Amazon S3 WordPress New User

In the next screen, assign a username and tick the box next to 'Programmatic access'. Then click the 'Next: Permissions' button at the bottom of the screen.

Amazon S3 WordPress User Access

In the next screen, opt to attach an existing policy and then hit 'Create policy'.

Amazon S3 WordPress User Create Permissions

In the window that automatically opens, select the JSON zone. Once again, we'll need a snippet of JSON code.

Remove any existing text and copy-paste in the following.

{
	"Version": "2012-10-17",
	
	"Statement": [
	{
		"Effect": "Allow",
		"Action": [
			"s3:CreateBucket",
			"s3:DeleteObject",
			"s3:Put*",
			"s3:Get*",
			"s3:List*"
		],
		"Resource": [
			"arn:aws:s3:::INSERTBUCKTNAMEHERE",
			"arn:aws:s3:::INSERTBUCKETNAMEHERE/*"
		]
	}
	]
}

Now select 'Review policy' below the JSON window. In the next screen, you don't need to do anything except provide a name for the policy.

You will now be returned to the IAM dashboardOpen the 'Users' tab again and hit 'Add user'. 

Amazon S3 WordPress New User

Like before, name your user and give them 'Programmatic access', then, do the following:

  • Click 'Attach existing policies directly'
  • Hit the small refresh icon
  • Search for your policy
  • Tick your policy when it appears
  • Click 'Next: tags'
Amazon S3 WordPress Select Policy

In the following screen, set a user access ID and Key and hit the 'Next: Review' button. It doesn't really matter what you enter. AWS will create its own ID and Key later.

Amazon S3 WordPress Access Keys

In the review screen, just hit 'Create user'.

Amazon S3 WordPress Create User

Amazon will now give you an autogenerated ID and key combo to use. Record both in a safe location!

Amazon S3 WordPress User Created

6. Edit Your WordPress wpconfig.php File

You're officially finished configuring your S3 account, so it's now time to turn your attention to the WordPress side of things. Initially, we need to add the S3 user keys to your WordPress configuration file.

Through your control panel, open your WordPress host's FTP service and navigate to WordPress's root installation folder (normally called 'public_HTML').

Then, find and edit the 'wp-config.php' file by right-clicking on it and pressing 'Edit':

Amazon S3 WordPress FTP edit

Copy and paste the following at the top of the file, under the green text, replacing the access ID and key where appropriate.

define( 'AS3CF_SETTINGS', serialize( array(
    'provider' => 'aws',
    'access-key-id' => 'INSERTACCESSIDHERE',
    'secret-access-key' => 'INSERTACCESSKEYHERE',
) ) );

If the file now looks like the screen below, click 'SAVE & CLOSE'.

Amazon S3 WordPress FTP Edited Config

7. Choose a WordPress S3 Plugin

Now decide which S3 plugin to use. There are several to choose from. Below, I'll be demonstrating the setup process with WP Offload Media Lite as it's free and works well with newly uploaded files. Note that if you want to sync an existing WordPress media library then W3 Total Cache or Media Library Folders Pro may be better choices.

8. Install and Configure Your S3 Plugin

I won't dwell on the installation process here. If you aren't sure how to add a plugin, check out this guide on How To Install WordPress PluginsOnce your plugin of choice is installed and activated, configuring it is shockingly simple.

You did the hard work already!

If you chose WP Offload Media Lite, open the plugins section of the sidebar and click 'Settings' under the plugin name.

Amazon S3 WordPress Plugin Settings

In the settings window, select the default option which is to 'Define access keys in wp-config.php'.

Amazon S3 WordPress Add Access Keys

In the next screen, simply enter your bucket's name and click 'Save Bucket'.

Amazon S3 WordPress FTP Save Bucket

And that's it, congratulations! You've successfully created a system to make WP offload S3.

Setting Up Amazon S3 WordPress Site - Final Thoughts

If you used the WP Offload Media Lite plugin, any new media you add to your WordPress will now be automatically stored in your S3 bucket.

That's great if you're just starting a new WordPress site.

However, if you already have an extensive back catalog of uploaded media, it's likely worth upgrading to a paid plugin to transfer pre-existing content.


Avatar
Bart Keating

Experienced in copywriting, SEO and creative writing (journalism, blogging, poetry, lullabies etc.). Public communication bachelor and HoReCa expert. A strange sense of humor but bearable. Has a beard, a cat, a fiancee, a hedgehog, and a brand new pug.


Related posts

5 Best Windows Cloud Storage Solutions – Keep Your Files Safe!
Avatar gfdgdgdgdgd Bart Keating

0 comments

2019 January 30th

If your Windows computer is filled with irreplaceable documents and photos, it’s important to protect those files with a backup.  And it's best to...

Amazon Cloud Drive Review – Is Amazon a Prime Cloud Provider?
Avatar gfdgdgdgdgd Paul Mahony

1 comments

2019 January 7th

Amazon Cloud Drive is a just another product from Amazon - the world's largest online retailer. Cloud storage is one of many, many businesses this...

GoDaddy Switches Servers To Amazon Web Services
Avatar gfdgdgdgdgd Paul Mahony

0 comments

2019 August 16th

Is it just balancing the books, or is it the beginning of the end... In March 2018 Amazon Web Services (AWS) announced, that one...

Top 3 Hosting Providers
Hostinger logo
9.5 /10
BlueHost logo
9.4 /10
GoDaddy logo
9.1 /10
Leave a Comment

1 comments

Ken Cooper picture
Ken Cooper

2019 June 21st

An extraordinary article that really does describe the “AWS-WP” linking process. Very, very seldom that I have seen an article so accurately done.

THANKS – Ken