So, I have now setup Amazon S3 and Amazon CloudFront and it looks pretty good! It has taken quite a bit of work, but I have managed to have all static files served by Amazon CloudFront.
I know a lot of other bloggers are probably wondering how they can setup Amazon S3 and CloudFront to work with their blogs so I have prepared a step by step walkthrough below.
First, lets gather a list of all files that we are going to store on amazon S3.
You should now navigate to the WordPress directory on your server. Generally, it can be located at /home/user/public_html or /var/www/ or similar.
Type in the following:
CD FilePath
Of course, replace FilePath with the actual location of WordPress on the server.
After that, you are going to want to run a query on your file system. The command listed below should be run in the SSH terminal, it will output a list of files we need to download.
find * -type f ( -name *.css -o -name *.js -o -name *.png -o -name *.jpg -o -name *.gif -o -name *.jpeg ) >> files.txt
Now we need to generate a zip file with all of our data so that we transfer it to Amazon.
Now, we are going to make a zip file. Use the following command:
zip -r files . -i@files.txt
Now you should have generated a zip file, files.zip with all of the contents we need to upload to Amazon S3.
Now, to download and delete that zipped file…
We now need to download the zip file we just created. Visit your WordPress blog (in my case, mattdsworld.com).
Simply append /files.zip to the end of the url. For example I would download the files from mattdsworld.com/files.zip.
Now we need to be patient. Let the file download completely to your desktop, in some cases this will be faster than others.
You can now delete the temporary files we created from the server. Enter the following in the command line to do so:
rm files.txt
rm files.zip
Y0u are done with your server for now at least!
Finally, its time to get everything on S3!
Hopefully you already have S3Fox and Firefox installed, but incase you don’t I have found a great video tutorial which will help you get started with S3Fox.
Look on the very bottom right corner of Firefox, you should see the text S3Fox/logo, click on it. You should see a create Bucket Symbol
. Click it. Your bucket name must be unique accross all of Amazon S3 so I recommend setting it to something like images.yourdomain.com. For example, I used images.mattdsworld.com. Once you name your bucket, click okay.
Double click the bucket you created (it will be displayed in a list below those buttons).
Now, extract that zip file you downloaded earlier. Once extracted, select all files, and drag them into the white area where your bucket was listed earlier.
Wait… You should be in the Transfer View tab. Scroll all the way to the bottom, and wait until the last object shows Completed.
Now, time to set our permissions up…
Since everything is now uploaded we are going to have to set permissions. Go back to the Remote View Tab (click on it near the top of the S3 Firefox Organizer window).
You should now see 3 folders. Click on the first folder, hold shift and click on the last one.
Now, right click over any of the selected folders and select Edit ACL.
You can click on The Green Checkmark and Red Crosses to switch them. Make sure they are setup like the picture below.

Also, be sure to check the box beside “Apply to subfolders”.
Now you can click okay, your bucket is setup!
Now, to test it out… Loading your Amazon Bucket!
For example, I would load:
http://images.mattdsworld.com.s3.amazonaws.com/wp-includes/js/autosave.js
Replace images.mattdsworld.com in that url with your bucket’s name.
If the first line reads the same as it does below, we are ready to go! If you see an XML sheet, try reapplying the permissions. If that doesn’t work post a comment below and I’ll try to help you.
var autosaveLast = ”;
Finally, I can say that all of the confusing work is over.
Time to setup WordPress to load files from Amazon S3, don’t worry, its easy!
Log into your WordPress Admin Panel, click Plugins from the menu on the left, then Add New below that.
In the search box enter My CDN and then press enter. The first result should be My CDN. Click install on the right side.
Now click on Plugins again, it should bring up a list of plugins including My CDN. Click activate to the right of My CDN.
The plugin is ready to be configured, just one more step, really!
Still under the admin panel click on settings. You should now see My CDN in the sub menu below it, click on My CDN.
Your blog’s main URL should already be entered, if it isn’t be sure to enter it here. You may want to add your website with and without the www. if it can be accessed both ways, simply enter
http://mattdsworld.com,http://www.mattdsworld.com
Replacing mattdsworld.com with your domain name of course!
Leave the “Excluding URL Patterns” textbox alone.
Now there should be 3 more text boxes below. In all of them we will enter the same thing. You are going to have to recall your bucket name one last time.
Enter the following in each box:
http://images.mattdsworld.com.s3.amazonaws.com
Be sure to replace images.mattdsworld.com with your bucket name.
Click Save Changes!
And you’re done!
If you have any problems, feel free to send an post a comment below and I will try my best to help you!


















Thanx kindly for linking to my Amazon S3 tutorial! I had a lot of fun making it and am THRILLED you dig it! Useful tutorial you’ve done, I hope others get goodness out of it too.
Thanks for the comment Torley, I also left one on your blog. Your tutorial is awesome and makes a perfect reference for this!
Very useful and instructional tutorial. This really shed some light on how this whole crazy Amazon S3 service really works and how to get started with it. Awesome!
I always enjoy learning what other people think about Amazon Web Services and how they use them. If you want to manage Amazon S3 accounts on Windows check out my freeware product CloudBerry Explorer. http://cloudberrylab.com/
Thanks for a great tutorial.
The instructions seem to be for copying over existing files, but what do you do about photos and stuff that you upload in the future?
I like to use tantannoodles.com/toolkit/wordpress-s3/
Its quite straight forward to install
Hi, thanks for the tutorial, but I got some questions.
1. Is this tested with WordPress 2.8?
2. The find command go get the files must be entered inside your theme directory, right? If you go to wp directory you would end finding all images uploaded.
3. Cant get your find command to work in Mac OS X.
4. I copied all images, put inside a img.gusleig.com bucket and in the MyCDN config panel entered that in the Theme file pre-URL, I left other 2 text box above empty. When I reload my webpage seems that its getting images from my server, like nothing is changed.
1. Its been working for me on every version I’ve tested, really it depends on the plugins I guess.
2. Run the find command on the server. I wouldn’t bother uploading uploaded images, I’d use a separate plugin for that, but you shouldn’t need to upload them.
3. See 2.
4. Did you keep the directory structure? And, myCDN is pointing to img.gusleig.com.s3.amazonaws.com?
I would appreciate very much if somebody tells me on how do I get the embedding code of the videos I have on my bucket. Is that possible? I can get the URLs, but I am lost about those embedding codes.
Thanks
Hmm, it would be the same embedding as normal. If you’re using wordpress, use the plugin I mentioned earlier, http://tantannoodles.com/toolkit/wordpress-s3/
Then you can just select the video and it will take care of embedding it. Otherwise, try:
autostart="TRUE/FALSE" />
Regards, Matt
If you liked this article, tweet it or link to it from your blog!
Thanks for you response Matt.
One more question. Do you think that all the rewriting rules can push more CPU power from the server?
thank you again.
By that, do you mean that using amazon S3 will speed up other things? Well, it depends.
If you have Nginx or a professional setup, you probably won’t notice a difference yourself, only the users and your bandwidth will. If apache is accessing the file system each time and you are on a shared or cheap VPS hosting account, you will most definitely push more power. Weather you will notice that is another question.
Regardless, I use CloudFront with S3 for the sole purpose of the user experience. I can say that except during traffic bursts (dig first few pages), I don’t notice a difference.
Great tutorial!
Do you think it would work in the same way with WPMU?
Cheers,
It depends if WPMU supports plugins the same. If it does it *should* work.
I’m not the best when it comes to command line bash commands but I get this error when using the find command you provided above:
-bash: syntax error near unexpected token `(‘
Any ideas?
Ken, remove the brackets. Had same error on Fedora Core 8
Good tutorial – thanks for sharing.
Question -
can anyone please show/tell me how to get the same security features as this Amazon S3 / WP plugin http://bucketfly.com for $98 ?
It looks good, but i can’t afford it right now and need those features to protect exclusive content on a membership site
…or does that require separate scripts to handle additional functions for creating dynamic links to prevent hot-linking or sharing?
Thanks for any help
Donald, I don’t really see a way to do that with the plugin I mentioned, and I couldn’t find anything that would do that free after a quick search. Your best bet is probably to buy that, $98 is really cheap, if I was to build out such functionality for a client, this could easily run up a 3-4 thousand dollar bill, of course, it would be built to their exact standards rather than a general audience’s hopes/expectations.
its the greatest tutorial for new webies and for people who need it