Install gem

gem install capistrano

Generate a key


Copy  the key without white spaces or any extra characters.


Now login to and add the publilc key into deployment keys of your repo admin menu.

create a deployment file

mkdir /var/www/deploy
capify .

edit the /var/www/deploy/config/deploy.rb as follows

#require ‘bundler/capistrano’
#require “rvm/capistrano”

#set :rvm_ruby_string, ENV[‘GEM_HOME’].gsub(/.*\//,””) # Read from local system
set :rvm_ruby_string, ‘1.9.3’
set :rvm_type, :system

set :application, “APP name”
server “URL”, :web, :app, :db, :primary => true
set :user, “root”
set :deploy_to, “/var/www/#{application}”
#set :deploy_via, :remote_cache
set :use_sudo, false

set :scm, :git
#set :repository, “”
set :repository, “”
set :branch, “master”

Deploy through the following commands

cap deploy:setup
cap deploy:cold
cap deploy

Import the database with production environment

rake db:migrate RAILS_ENV=production