awswordpress-pro

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 WP Offload Media Lite for Amazon S3, DigitalOcean Spaces, and Google Cloud Storage 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 WordPress /opt/bitnami/wordpress/wp-config.php configuration file in a text editor and add the following lines to the file, after the initial <?php PHP tag:

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

    Remember to replace the XXXX placeholders 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 “Settings -> Offload Media” menu item. Select the “Amazon S3” radio button and click “Next”.

  • Click the “Create new bucket” link. You can also choose an existing bucket if you prefer.

  • On the resulting page, create a new S3 bucket to store your WordPress media files by selecting a region, entering a unique bucket name and clicking the “Create New Bucket” button.

  • 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 Bucket” and “Rewrite Media 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 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 image information panel, which shows the S3 bucket URL for the image.

S3 usage in WordPress

Last modification April 5, 2023