I’ve integrated Amazon S3 with the very handy (and open source) S3 Uploads WordPress plugin, which automatically uploads files to S3 and rewrites URLs from your website to serve them from there.
Step 1: Install WordPress CLI
- Connect via the terminal access on your server
- Install the WordPress CLI (if not already installed):
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
sudo chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
Step 2: Install S3-Uploads WordPress Plugin
- Download the S3-Uploads WordPress plugin and place it in your wp-content/plugins folder:
mv S3-Uploads-master/ /wp-content/plugins/S3-Uploads
Step 3: Activate S3 Uploads
- Now activate the plugin via the WordPress CLI:
wp plugin activate S3-Uploads
- In order for the plugin to work, you need to store appropriate Amazon Credentials in your config file. In the Amazon Console, add a new IAM user with only access to control your S3 bucket. Then place the credentials and S3 bucket details in your wp-config.php file:
define( 'S3_UPLOADS_BUCKET', 'blog.evandavey.com' );
define( 'S3_UPLOADS_KEY', 'xxxxxxxxxxxxx' );
define( 'S3_UPLOADS_SECRET', 'xxxxxxxxxxxxx' );
define( 'S3_UPLOADS_REGION', 'ap-southeast-2' );
define( 'S3_UPLOADS_BUCKET_URL', 'https://s3-ap-southeast-2.amazonaws.com/blog.evandavey.com' );
- You’re now all set! All new files uploaded will be automatically copied to S3, and their URL rewritten to that endpoint
Step 4: Sync existing files to S3 (Optional)
- If you have an existing site, you may wish to migrate all your files up to S3. To do this:
wp s3-uploads verify
wp s3-uploads --sync upload-directory wp-content/uploads/ s3://uploads/
Note: There is currently a bug in the S3-Uploads plugin which causes an error when you run the above:
Fatal error: Class 'Aws\S3\Sync\UploadSyncBuilder' not found
To fix this:
And remove reference “extends Aws\S3\Sync\UploadSyncBuilder”
It’s been a while since I wrote a blog post (over 5 years!) and in republishing my blog, I wanted to ensure a few best-practices were in place. One of those is ensuring that all content is served up over HTTPS.
Thankfully, we’ve come a long way in the past 5 years when it comes to providing a simple and cost free way to serve content using HTTPS – with thanks to the CA LetsEncrypt, you can now generate free SSL certificates with ease:
- Step 1: Head over to the CertBot from EFF
- Select your OS and web server
- Follow the step-by-step guide to install CertBot
- Bam! You’re running under HTTPS
Because Certificates from LetsEncrypt are only valid for 90 days, you need to setup a cronjob to renew the certificate. I do this on a weekly basis as follows:
letsencrypt renew --post-hook "service apache2 reload"
If you’ve open the terminal and run the “svn” command just to be told “-bash: svn: command not found” then do the following:
1) Install XCode
2) Open “Preferences” and click the “Accounts tab”
3) Add your Apple ID
4) Open the “Downloads” tab
5) Click the download link next to “Command Line Tools”
6) You have SVN!
The signature function in Mac OSX Preview is awesome. Easy to use, easy to generate, its a great way to “digitally” sign documents. However there is a problem when people send you portrait documents that have been saved in landscape. When you try to sign them, the signature appears sideways!
Here’s how to solve it:
1) Open the PDF is Preview
2) Choose “File -> Print” from the Menu
3) Save as “PDF”:
4) Close the document
5) Open the newly created PDF
6) Choose the signature option – and it will appear the right way up!
The team at Two Bulls have just posted a really nice page on their Augmented Reality technology. Based in Melbourne, Two Bulls provide a range of development services including Augmented Reality, iOS and Android Development and come highly recommended.
I’ve recently got into amateur photography, picking myself up a Canon 550D digital SLR and snapping away on a variety of trips over the past few months. In that light, Russell Spence has just launched his photography website, which includes some great landscape and nature shots. You can check out the full collection at russellspence.net
Our very good friends at Two Bulls have just launched their new website at two-bulls.com. The striking design is appropriate given they specialise in “immersive” mobile applications. Checkout their multi-award winning app The Hidden Park for an example.
Currently with offices in Melbourne and New York, Two Bulls also provide a range of specialist mobile consulting services to leading global brands and businesses. They recently relocated their melbourne office, and to celebrate, had a cake made featuring their logo – very cool.