Deploying WordPress on Amazon Opsworks with git

We’ve been spending a lot of time with Amazon Opsworks. We already use Amazon EC2 for most of our server and web application hosting, and were using Opscode Chef to handle a lot of the deployment – so Opsworks is a logical next step.

We’ve just successfully set up SugarCRM using Opsworks, and that’s been really successful. Next up – moving our WordPress sites over.

Version controlling WordPress with Git

The first step for us was to begin managing our WordPress codebase with Git. The core WordPress code is already available as a git repository, of course (eg. at the WordPress Github repo).

We followed David Winter’s guide to managing custom WordPress sites with git. The idea is to check out the WordPress code as a submodule in your git repo, and then set up separate git repos for your themes. Finally, he suggests version controlling the whole thing, allowing you to manage / version the config as well.

Once you have a Git repo for your WordPress, you can then add a new app in Opsworks. We use BitBucket for our version control, so we put the BitBucket repo address for our WordPress git repo into the Repository URL field in the App setup, and pasted our private BitBucket key into the “Deploy SSH Key” field as normal.

Deploying WordPress on Opsworks

Deploying the app gives you a checked-out wordpress directory in a minute or two.

Next step is to manage that config file using a custom chef cookbook. I’d like to put relevant data, like the database connection details, into custom JSON in Opswork, and use that to populate the wp-config file. We’ve already done a similar setup using a SugarCRM cookbook, for deploying Sugar on Opsworks, and that works really nicely – making it super-easy to set up subsequent sites. I’d like to get the same thing for all our WordPress sites — eg. the idea is that, in a couple of clicks, you can bring up a new WordPress site, with new database credentials and custom themes. I’ll be working on this over the next few days, so stay tuned for that…

Are you managing WordPress on Opsworks in a different way? Do let me know in the comments!