Capistrano: Deploying Ruby on Rails Applications to Multiple Servers

For a basic deployment recipe, check out Basic Deployment with Capistrano

This episode demonstrates how to extend deployment to deploy to stage and production. Overall it’s rather simple. All it entails is creating a new task for each stage you want to deploy to with the settings you need changed.

Here’s an example:

task :stage do
role :web, “” # Your HTTP server, Apache/etc
role :app, “” # This may be the same as your `Web` server
role :db, “”, :primary => true # This is where Rails migrations will run

set :deploy_to, ‘/var/www/stage-teachmetocodeacademy/’
set :user, ‘deploy’

That will allow you to run `cap stage deploy` to deploy to your staging environment.


Download 55.3 MB
Download (iPod & iPhone) 35.1 MB

{ 3 comments… read them below or add one }

Eric Berry June 27, 2011 at 9:56 pm

This is also possible with the capistrano-ext gem. View


Charles Max Wood June 28, 2011 at 3:46 am

Thanks Eric. I didn’t realize that they had picked up maintenance of that gem again. It hadn’t been maintained last time I needed it.


Wxianfeng March 29, 2012 at 2:48 am



Leave a Comment