Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Capistrano tasks for deploying Rails applications using Ubuntu 10.04, rbenv, nginx, Unicorn and PostgreSQL
branch: master

This branch is 15 commits ahead of cwsaylor:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

Note: this fork has an error when setting up redis due to the init script. Requires work arounds. If you can assist with the redis init script please let me know!

Cap Bootstrap

Capistrano tasks for deploying Rails applications using Ubuntu 10.04, rbenv, nginx, Unicorn and PostgreSQL. Based on the excellent Railscasts by Ryan Bates, with permission of course. If you are new to Capistrano or setting up a VPS, I highly recommend subscribing to his pro screencasts and watching the following:

I am not affiliated with Railscasts, I'm just a fan.


  • Capistrano
  • Fresh Ubuntu 10.04 or 11.10 install


Add these lines to your application's Gemfile:

gem 'capistrano'
gem 'cap_bootstrap'

And then execute:

$ bundle


Setup a new Ubuntu 10.04 slice. Add a user called deployer with sudo privileges.

$ adduser deployer --ingroup admin

On your local machine, install ssh-copy-id:

$ brew install ssh-copy-id

Then, copy your ssh certificate onto your new slice form your local machine:

$ ssh-copy-id deployer@slice.ip.address

After testing that you can ssh into your slice, open your sshd configu file on your slice, in order to imporve security:

$ sudo nano /etc/ssh/sshd_config

The main things to change (or check) are:

Port 30000          <--- change to a port of your choosing
Protocol 2
PermitRootLogin no
PasswordAuthentication no
UseDNS no
AllowUsers deployer

Save your changes and reload your sshd file:

$ sudo /etc/init.d/ssh reload

Your slice is now ready, but remember the following:

  1. Use the same port as above when ssh-ing into your slice in the future.

    i.e. ssh -p 30000 deployer@

  2. Set the :port variable in your deploy.rb (more info below) to the same port used in your sshd config file.

    i.e. set :port, 30000

In your project, run the following:

$ capify .

Then run this generator with an optional IP address to copy over a deploy.rb that is more suited to this gem. The application name defaults to the same name as your rails app and the repository is pulled from your .git/config.

$ rails g cap_bootstrap:install

Double check the settings in config/deploy.rb and then run:

$ cap deploy:install
$ cap deploy:setup
$ cap deploy:cold

Advanced Options

Shown below are the default advanced settings, but they can overridden.


set(:domain) { "#{application}.com" }


set :postgresql_host, "localhost"
set(:postgresql_user) { application }
set(:postgresql_database) { "#{application}_production" }


set :ruby_version, "1.9.3-p125"
set :rbenv_bootstrap, "bootstrap-ubuntu-10-04" # Or bootstrap-ubuntu-11-10


set(:unicorn_user) { user }
set(:unicorn_pid) { "#{current_path}/tmp/pids/" }
set(:unicorn_config) { "#{shared_path}/config/unicorn.rb" }
set(:unicorn_log) { "#{shared_path}/log/unicorn.log" }
set :unicorn_workers, 2

Future Plans

Version 0.1 uses Ryan's recipes pulled directly from Railscast episode #337 Capistrano Recipes. You will always be able to access this version with tag v0.1.

Future versions will incorporate optional installs such as MySQL, Apache, Phusion Passenger and additional server config such as setting a hostname. Also considering changes to allow deploying multiple apps onto a single server and provisioning Linode slices using their api.



  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.