AWS S3 WordPress Integration

I am a big fan of AWS services. They are highly available and scales out of the box. The article explains how you can use AWS S3 as your storage engine for your wordpress blogs using wordpress s3 plugin.

Why AWS WordPress integration?

  • AWS S3 scales out of box with infinite storage capacity and utilize benefit by taking wordpress into cloud.
  • Its extremely useful in case in future you want to change your hosting service. For.e g. I am using dedicated server for hosting my website. By default media data is stored on the server wp-contents/uploads/ directory. If I want to change my server or say hosting service, I don’t have to take headache of migrating user images, media images, featured images to new hosting service.
  • Increases performance of your wordpress website as media files are not served by your wordpress server. Reduces load on your wordpress web server.
  • Keeps storage layer separate from web server layer making it efficient.
  • Saves disk space on your wordpress servers. With AWS S3 you have infinite storage space.
  • You can use AWS CloudFront facility with AWS S3 out of box as CDN(Content Delivery Network).
  • AWS S3 charges are negligible. You can check pricing details here. Pay as per your usage. For free tier users like me, we don’t have to pay anything until your traffic grows.
  • This architecture is highly scalable with very low maintenance headache.

Assumptions

  • You have an AWS account and you have IAM access to AWS S3 service.
  • You know how to install wordpress plugins.
  • You have access to your wordpress hosting service and write permission to wp-config.php.

AWS WordPress Plugins Needed

We are going to install and configure below two aws wordpress plugins. We will follow steps to migrate wordpress on aws.

  • Amazon Web Services
    • It contains AWS php libraries and stores s3 access key and secret.
    • It acts as AWS keys manager.
  • WP Offload S3
    • Amazon S3 and CloudFront wordpress plugin which uploads your file directly to s3.
    • Allows to integrate wordpress with AWS CloudFront for faster delivery of media files.

Steps for AWS S3 Setup

  • Login to your AWS account with root credentials.
AWS WordPress integration for Media Files

AWS WordPress integration for Media Files

  • Create a user. AWS strictly advocates to perform all S3 operations like read, write through an user for security reasons.
  • Give this user AmazonS3FullAccess from the policy section.
AWS S3 WordPress Integration AWS S3 Policy

AWS S3 WordPress integration AWS S3 Policy

  • Generate AWS S3 access keys and secret. It’s for one time use only. In case you lost secret key, you need to generate new keys again. Download  and safely store at secure location.
AWS S3 WordPress Integration AWS S3 Access Key

AWS S3 WordPress integration AWS S3 Access Key

  • We will be needing generated AWS access key and AWS secret key in below configurations.

Steps AWS S3 WordPress integration

     AWS WordPress Plugin “Amazon Web Services” Installation

  • Download and install Amazon Web Services plugin with our goal of setting up wordpress media files on AWS. Activate this plugin.
  • You will see AWS icon on left side of your wordpress Admin.
  • Click on the icon. You will be asked to make changes in wp-config.php.
AWS WordPress Integration with Amazon Web Service Plugin

AWS WordPress integration with Amazon Web Service Plugin

  • Open wp-config.php and add your access key and access secret which you generated above. Since I have dedicated server I had to login to my server and make changes on server wp-config.php.
  • If you have private git repository for your wordpress website you can commit to wp-config.php and deploy the file.
  • It says you can’t commit to your repository. However if you have private repository there is no issue in committing.

      AWS WordPress Plugin “WP Offload” Installation

  • Download and install wordpress WP Offload S3 plugin. Activate it and go to it’s settings page. You will be asked for bucket name.
  • You can either create new bucket or chose if you have already created. Don’t create too many buckets. Remember all your images are going to reside in this bucket in different folders.
WordPress AWS Setup for Media Files

WordPress AWS Setup for Media Files

  • wp-content/uploads/ is the default path. All your media, images, video file will be uploaded in this directory. You can change the path if needed.
  • In Advanced options enable below configurations
    • Remove Files From Server
    • Object Versioning
  • Great! Your amazon S3 setup is done. You can test by uploading one of your blog featured image again. You will see that your images are being stored in wp-content/uploads/ directory. Images format are in datetime format e.g. 20150815134504.
WordPress AWS Setup for WordPress Cloud

WordPress AWS Setup for WordPress Cloud

Migrate WordPress Existing Media Files to AWS S3

Below are ways by which you can migrate your existing images, videos or any other media files to AWS S3:

  • Delete and re-upload the images.
  • Manually upload to S3 and update your posts with new image location.

I strongly recommend first approach since it’s more safer and take care of all references.  WP Offload S3 plugin premium features include uploading existing media library files to S3.

I strongly recommend to use AWS S3 and CloudFront with your wordpress blog specially if you are a professional blogger and expecting huge traffic.

I never tried bulk migration of media files with Offload S3 plugin. Let me know in comments if any one of you tried bulk migration with premium WP Offload S3 plugin.