Enable Amazon Cloudfront CDN in WordPress

I was setting up a wordpress web site to use Amazon S3 + Cloudfront as CDN. I used w3 total cache plugin for this. w3 total cache plugin have option to auto create Amazon S3 bucket and cloudfront distribution, for for this, you need to give Amazon AWS API keys.

WordPress CDN Setup W3 Total Cache

Clicking the button “Create as new bucket with distribution” will auto create s3 bucket and cloudfront for you.

if you site have images already uploaded, you need to upload them to Amazon S3. This can be done with W3 Total Cache.

Upload WordPress media to CDN

If you have lot of files, upload may fail. You may need to use Amazon AWS CLI tool to do the upload.

aws s3 sync /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/ s3://your-bucket-name/wp-content/uploads/

If needed, you can upload themes and plugins folder too

aws s3 sync /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/ s3://your-bucket-name/wp-content/plugins/
aws s3 sync /opt/bitnami/apps/wordpress/htdocs/wp-content/themes/ s3://your-bucket-name/wp-content/themes/

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *