Capistrano: Deploying Ruby on Rails Applications to Multiple Servers

For a basic deployment recipe, check out [Basic Deployment with Capistrano](https://teachmetocode.com/screencasts/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, "stage.teachmetocodeacademy.com" # Your HTTP server, Apache/etc role :app, "stage.teachmetocodeacademy.com" # This may be the same as your `Web` server role :db, "stage.teachmetocodeacademy.com", :primary =\> true # This is where Rails migrations will run set :deploy\_to, '/var/www/stage-teachmetocodeacademy/' set :user, 'deploy' end That will allow you to run `cap stage deploy` to deploy to your staging environment.  [Download](https://traffic.libsyn.com/tmtc/TMTCMultistageDeploy.m4v) 55.3 MB[Download (iPod & iPhone)](https://traffic.libsyn.com/tmtc/TMTCMultistageDeploy_-_iPhone.m4v) 35.1 MB

Sign up for the Newsletter

Join our newsletter and get updates in your inbox. We won’t spam you and we respect your privacy.