Assumes you have Ruby on Rails application already.
Setup Ruby Version, Unicorn and Capistrano
Specifiy a ruby version for your app by creating a new file in the root of your app called “.ruby-version” that includes:
1
|
|
Make the following changes to the Gemfile:
1 2 3 4 |
|
Type command below to install gems:
1
|
|
Type command below to install binstubs for capistrano:
1
|
|
Configure Capistrano
Type command below to initialize capistrano:
1
|
|
Add the following below require ‘capistrano/deploy’ in the Capfile in the root of your app:
1
|
|
Add or Replace this configuration in config/deploy.rb file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
After the configuration in /config/deploy/production.rb with your server ip or domain name:
1 2 3 |
|
Configure Unicorn
Create a new file config/unicorn.rb with the following contents:
1 2 3 4 5 6 7 8 9 |
|
Comment out production username and password from config/database.yml:
1 2 3 |
|
Type command below to push changes to git:
1 2 3 |
|
Type command below to create a secret to be used on the server:
1
|
|
On the server setup the secret by modify /home/deploy/.bashrc with the following contents:
1
|
|
On the server restart nginx, type command below:
1
|
|
Deploy
Type command below to make sure capistrano is connected to the server:
1
|
|
Type command below to make sure can deploy or not:
1
|
|
Type command below for deploying:
1
|
|
If you need to run db:seed, log into server as the deploy user and run following:
1
|
|
If you are having problems, try running a console on the server, log in as deploy user and run the following:
1
|
|