Capistrano Rails Deploy without SVN or Git

I needed this post when I was just starting on Rails and didn’t know how to set-up SVN and/or Git. I used Blue Box Group Rails Shared Hosting and the really-easy-to-deploy with Capistrano.

It’s pretty easy and I will go through it step-by-step.

1. If you don’t have Capistrano installed go ahead and install it. Using Terminal, copy and paste:

gem install capistrano

2. Tell Capistrano You will Deploy with it in Terminal

$ cd your_apps_folder

$ capify .

[add] writing ‘./Capfile’

[add] writing ‘./config/deploy.rb’

[done] capified!

3. Configure deploy.rb

Just copy and paste this special deploy.rb that just uses your local folder on your computer, no need for Subversion (SVN) or Git:

# Your Applications “Name”
set :application, “Application Name”

# The URL to your applications repository
set :repository,  “.”
set :scm, :none
set :deploy_via, :copy

# Require subversion to do an export instead of a checkout.
set :checkout, ‘export’

# The user you are using to deploy with (This user should have SSH access to your server)
set :user, “Your SSH User”

# We want to deploy everything under your user, and we don’t want to use sudo
set :use_sudo, false

# Where to deploy your application to.
set :deploy_to, “/domains/Your Domain/”

# ——————————– Server Definitions ——————————–
# Define the hostname of your server. If you have multiple servers for multiple purposes, we can define those below as well.
set :server_name, “”

# We’re assuming you’re using a single server for your site, but if you have a seperate asset server or database server, you can specify that here.
role :app, server_name
role :web, server_name
role :db, server_name, :primary => true

# ——————————– Final Config ——————————–
# This configuration option is helpful when using svn+ssh but doesn’t hurt anything to leave it enabled always.
default_run_options[:pty] = true

namespace :deploy do
task :restart do
run “touch #{deploy_to}current/tmp/restart.txt”

task :start do
run “cd #{deploy_to} && ln -s current/public public_html”
run “touch #{deploy_to}current/tmp/restart.txt”

task :symlink do
run “cd #{deploy_to} && rm current ; ln -s releases/#{release_name} current”
run <<-CMD
rm -rf #{latest_release}/log /home/#{user}/#{latest_release}/public/system #{latest_release}/tmp/pids &&
ln -s /home/#{user}#{shared_path}/log /home/#{user}#{latest_release}/log &&
ln -s /home/#{user}#{shared_path}/system /home/#{user}#{latest_release}/public/system &&
ln -s /home/#{user}#{shared_path}/pids /home/#{user}#{latest_release}/tmp/pids

task :stop do
run “rm #{deploy_to}public_html”

namespace :web do
task :disable do
run “cd #{deploy_to} && rm public_html && ln -s static_site public_html”

task :enable do
run “cd #{deploy_to} && rm public_html && ln -s current/public public_html”


task :after_setup do
run “rm -rf #{deploy_to}public_html”
run “mkdir #{deploy_to}static_site”

4. Setup the Server

$ cap deploy:setup

5. Do your Deploy

$cap deploy:cold

6 (optional). If this was your first deploy you may have to setup a symlink to public_html if using Blue Box Group Shared Hosting, all you have you have to do is the following after a successful deploy in step 5:

$ cap deploy:web:enable

Theoretically after that you should be able to just deploy with:

$ cap deploy:migrations

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>