Deploying your web app to multiple environments (e.g. development, test, production) is a cinch using Capistrano. Let me show you how.

Capistrano is written in Ruby, so this is your main pre-requisite. Get Ruby and Rubygems installed, and then simply type the following command to install the Capistrano gem:

gem install capistrano

Getting your application ready for deployment starts with the following command, issued from inside your app’s top-level directory:

capify .

This two files: Capfile and config/deploy.rb. The latter is where we are going to tell Capistrano how we want it to deploy our application.

set :application, "myapp"
set :repository,  "git@github.com:johngrimes/myapp.git"
set :scm, "git"

The first part of our deploy.rb gives our app a name and tells Capistrano where to pull the latest copy of our app from. This example has us using Github as our source code repository.

(more…)