Capistrano is deploy tool using Ruby.

Install Capistrano

Do you have Ruby? (>=1.9). That’s fine!

sudo gem install capistrano

Get Started test project

Let’s make test project and setting files

mkdir test
cd test
cap install

You can see config/deploy.rb, config/deploy/stating.rb, config/deploy/production.rb.

  • config/deploy.rb : Common settings and steps
  • config/deploy/staging.rb : Staging setting and tasks

staging is prod, dev, test, etc… steps env.

Common setting file(config/deploy.rb)

What kind of things does deploy.rb do?

  • Get source codes(git etc…)
  • Build, archive, create package
  • Install, start application etc…


  • Application name
  • Repository
  • Task
  • Task command

Default task


Target(staging) setting


Server settings

  • hostname
  • server role
  • login user
  • ssh
  • others


server 'localhost', user:'tomcat',roles: %w{web}

server hostname, user: username, roles: %{serverrole}

Run cap command

Run capistrano

cap staging deploy

This is example of staging. Target is config/deploy/staging.rb
Task is deploy