Deploy WordPress Automatically with Capistrano

I volunteered to help my wife convert her aging website to WordPress. In a past life I used to be a WordPress developer (*) and during that time I worked with several WordPress experts and picked up a few best practices. One practice I learned was to deploy WordPress from version control (subversion) so when WordPress gets hacked, you can easily see the changes and rollback.

So when it came time to setup my wife’s WordPress site, I turned to the deployment tool that I use on every one of my Ruby on Rails projects: Capistrano. Since I’m familiar with Capistrano’s code base from my Ruby code reading, I wanted to see if it could handle WordPress. Looking around, I found a few projects that already hooked up WordPress to Capistrano but Adam Hunter’s wp-cap was the simplest and most recent.

Basically it takes advantage of the standard public/ directory in Rails and deploys WordPress to there. With a few extra recipes, the entire WordPress deployment is automated. The entire Capistrano configuration file with the WordPress recipes is only 71 lines of Ruby and will automatically generate a wp-config.php.

Now I can work on her WordPress site just like in Rails:

  1. Hack on code
  2. git commit -m "New code"
  3. git push the-wordpress-server
  4. cap deploy
  5. Sip some silver needle white tea and chill

* The first major upgrade of WordPress I did was 1.5, so I must have been using it before then.

2 comments

  1. Max Mitchell says:

    How do you manage the other stuff that sits alongside WordPress, such as uploads, database backup, etc. If you wife uploads new content, how to do you make sure you’ve got everything in case the site gets hacked?

Comments are closed.