Setting up RubyOnRails environment on Ubuntu 14.04

This tutorial is about setting up environment for RubyOnRails on Ubuntu 14.04.

First of all, update & upgrade your system:

sudo apt-get update

^
sudo apt-get upgrade
^

Install git and curl:

sudo apt-get install curl

^
sudo apt-get install git-core
^

Configure git:

git config --global user.name "Your Name"

^
git config --global user.email email@example.com
^

Install RVM:

curl -sSL https://get.rvm.io | bash -s stable

^
source ~/.rvm/scripts/rvm
^
Test RVM installation correctness:

type rv...

Capistrano deploy.rb examples

All examples here for deploy RoR application with unicorn, staging machine (where we deploys) available via ssh by ssh_key.

  1. Deploy via remote_cache:

     require 'rvm/capistrano'
     require 'bundler/capistrano'
    
     set :application, '_proj_'
     set :rails_env, 'production'
     set :domain, '_user@your_deploy_domain_'
     set :deploy_to, "_path_to_#{application}"
     set :use_sudo, false
     set :unicorn_conf, "#{deploy_to}/current/config/unicorn.rb"
     set :unicorn_pid, "#{deploy_to}/shared/pids/u...
    

Deploy rails apps with capistrano

Install capistrano:

add to Gemfile

  group :development do
      gem 'capistrano'
      gem 'rvm-capistrano'
  end

Then cd to project root folder and run:

bundle install
capify .

setup your config/deploy.rb file, here some useful examples

cap deploy:setup #before first deploy
cap deploy:check #before first deploy
cap deploy:cold  # for first deploy
cap deploy #for subsequent deploys