Looking for a way to connect WordPress to Amazon S3 bucket? Then you’re in the right place. This article will guide through everything that you need to know.
Things You Need to Set up WordPress S3 Integration
You need these things ready:
- Amazon Web Services account, free to sign up for.
- A public Amazon S3 Bucket – during your first year, this is free and you’ll get 5GB storage.
- A WordPress S3 plugin – you will be able to automatically offload the files that you upload to your S3 bucket.
S3 Plugins You Can Choose
There are a few plugins you can try to connect WordPress to Amazon S3 bucket, each has its own different features.
- WP Offload Media Lite – great free version, but it only works with newly uploaded files. The Pro version allows you to be able to store and serve your assets from S3 and upload existing files. If you’re planning to use a CDN later, it will be very easy.
- W3 Total Cache – it includes a feature that allows you to connect your site to S3 if you choose S3 as your CDN in the settings.
- Media Library Folders Pro S3 – you can manage your WordPress media library while offloading all or some files at the same time to S3 and maintaining the same folder structure.
- Human Made S3 Uploads – it doesn’t have an interface. Available on GitHub, this project isn’t designed for casual users. Developers will like this one though.
For this tutorial to connect WordPress to Amazon S3 bucket, we’re using WP Offload Media Lite plugin because it’s the most popular plugin we know. Before you begin, you should back your site.
- Install and activate WP Offload Media Lite Plugin
The first step is making sure that everything is installed and activated on your site.
- Make a New bucket
After you create a free Amazon Web Services account, you can navigate to the S3 from inside of your AWS account dashboard and click create bucket button. Next, you can give it a name and choose a region and click create.
- Bucket Policy
To make sure that everything works properly, you need to make your bucket public. Simply click on your bucket interface, click on the Permissions tab and select Bucket Policy. Next you will see a JSON code editor, and paste in this code and save your changes. Replace asterisks with the name of your bucket.
- Create an IAM User and policy
Go to the IAM area in your AWS account, click Add Users at the top, give your user a name, select Programmatic access under Access type, and click Next: Permissions: it will open a new window, go to JSON tab and paste this
Click Review Policy, give it a name and click Create Policy. Go back to IAM Add User tab, click Refresh, select the new policy, click Next:Review. Next screen, click Create user, keep the Access key ID and Secret access key there.
- Add Access Keys to wp-config.php file
Edit your wp-config.php file via FTP or cPanel. Add this code, replace the asterisks with your code and save your changes.
define( 'AS3CF_AWS_ACCESS_KEY_ID', '********************' );
define( 'AS3CF_AWS_SECRET_ACCESS_KEY', '**************************************' );
- Select S3 bucket in WP Offload Media lite settings
Go to settings and Offload S3, type your bucket’s name and click Save Bucket. Now you have connected WordPress to Amazon S3 bucket.