awswordpress

Configure WordPress for cloud storage on Amazon S3

NOTE: Before following the steps in this guide, ensure that you have an Amazon Web Services account with (optionally) an IAM user account and the corresponding AWS access key and secret key. You should also install and activate the Amazon Web Services plugin and the WP Offload S3 Lite plugin in your WordPress blog (instructions).

To configure Amazon S3 storage for your WordPress blog, follow these steps:

  • Log in to your server console.

  • Open the file /opt/bitnami/apps/wordpress/htdocs/wp-config.php in a text editor and add the following lines to the file, after the initial <?php PHP tag:

    define( 'AWS_ACCESS_KEY_ID', 'XXXX');
    define( 'AWS_SECRET_ACCESS_KEY', 'XXXX');
    

    Remember to replace the XXXX placeholder in the above lines with your actual AWS access key and secret key.

    S3 configuration

  • Save the file.

Next:

  • Log in to your WordPress blog as an administrator.

  • Select the “AWS -> S3 and Cloudfront” menu item.

  • On the resulting page, create a new S3 bucket to store your WordPress media files by entering a unique bucket name and hitting the “Create” button. You can also choose an existing bucket if you prefer.

  • Once the bucket has been created, you’ll be transferred to a page where you can configure plugin behaviour. Ensure that the “Copy Files to S3” and “Rewrite File URLs” options are turned on. Other settings can be left at their default values or modified per your preference.

    S3 configuration

  • Click “Save Changes” to save your settings.

You can now add pages and posts to WordPress as normal. When you add a media file using the WordPress editor or media library, your media file will be uploaded to both the WordPress blog and the chosen S3 bucket.

The Amazon S3 and CloudFront plugin will automatically rewrite URLs so that the media is served from S3 instead of from your WordPress host. In the screenshot below, refer to the browser status bar, which shows the S3 bucket URL for the image.

S3 usage in WordPress