## deploy Rails to AWS ec2

### local machine

make sure you can ssh host_name connect to your remote server. ssh-add key.pem if neccessary.

Install capistrano, then in your local application dir
capify .
Then
require 'bundler/capistrano'

one more thing:

ok, let's deploy,
git push ec2 master # dont forget push first
cap deploy

Gone for this far, theoretically it should be easy for the rest. However, by my experiences, it's still highly possible to get stucked in any step by any kind of errors.

A command problem might be the shell environment. On one linux machine, there might be different shell environments, sh, bash, cth, ..etc, and different shell environments usually corresponding to different rvm/ruby/rails paths. To solve this problem, one may want to decide the shell environment you want to use in deployment.

By default, capistrano use sh. If you don't want it be your choice, set false in your deploy.rb, ref here:
default_run_options[:shell] = false
or you can specify your favorite, ref here :
default_run_options[:shell] = '/bin/bash' # I haven't test this yet

Once into your favorite shell, there might still be different rvm loading path. Try this, it works for me, ref here:
set :bundle_cmd, 'source \$HOME/.bash_profile && bundle'

good ref: here
this maybe: here, here