Skip to content

Commit

Permalink
adds deployment commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramesh Jha committed Feb 12, 2013
1 parent f2bffb0 commit 83e1f73
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 7 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
RailsonUbuntu
RailsOnUbuntu
=============

Some useful goodies for *Ruby on Rails* developers using Ubuntu!
Some useful scripts/goodies for *Ruby on Rails* developers using Ubuntu!

### 1 Rails Installer
### 1. Rails Installer

For setting Up Rails on Ubuntu 12.04 LTS (Precise Pangolin) / 12.10 (Quantal Quetzal)
I've also written a step by step guide for beginners, read the blog post - http://blog.sudobits.com/2012/05/02/how-to-install-ruby-on-rails-in-ubuntu-12-04-lts/

### 2. Deploying a Rails Application

Scripts/Commands for setting up a VPS for deploying rails application. For step by step instruction refer to the blog article - http://blog.sudobits.com/2013/01/07/how-to-deploy-rails-application-to-vps/

**If you're stuck and need any help, then put a comment there on the post (rather sending me an email).**

#### TODO

1. script for setting up a VPS
1. update the script for alternative options/configurations
2. capistrano recepies & more

License
MIT

Contact : Ramesh Jha (rameshjha420@gmail.com)
Contact : Ramesh Jha (ramesh[at]rameshjha.com)
http://blog.sudobits.com
135 changes: 135 additions & 0 deletions deploy-rails-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# A list of commands - for quickly setting up VPS for deploying Rails Application
# using nginx, Ubuntu(Latest Stable LTS : 12.04), Unicorn, MySQL and Capistrano
# Author: Ramesh Jha ([email protected]),(http://blog.sudobits.com)
# License: MIT

# setting hostname (optional)
echo "<YOUR_HOSTNAME>" > /etc/hostname
hostname -F /etc/hostname


# Update System Packages
apt-get -y update
apt-get -y upgrade


# fix for locale error on Ubuntu (optional)
apt-get install --reinstall language-pack-en
locale-gen en_US.UTF-8

# for apt
apt-get -y install python-software-properties

# install git and curl
apt-get -y install curl git-core

# Install Server (nginx)
apt-add-repository -y ppa:nginx/stable
apt-get -y update
apt-get -y install nginx

# start/stop nginx (in Ubuntu 12.04 LTS)
sudo service nginx start
sudo service nginx stop
sudo service nginx restart

# or

sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx restart


# For Installing nodejs
sudo apt-add-repository -y ppa:chris-lea/node.js
sudo apt-get -y update
sudo apt-get -y install nodejs

# Create User and add it to sudo group
adduser example_user --ingroup sudo


## setup keys for ssh login

# On Local Computer
ssh-keygen
scp ~/.ssh/id_rsa.pub example_user@IP_ADDRESS:

# On remote server
mkdir .ssh
mv id_rsa.pub .ssh/authorized_keys


# Install MySQL Database and its Dependencies
sudo apt-get -y install mysql-server libmysql++-dev

#create a production database (mysql)
mysql -u root -p
create database YOUR_DB_NAME;
grant all on YOUR_DB_NAME.* to DB_USER@localhost identified by 'your_password_here';
exit


# setup ruby
## Install rbenv using this installer
## https://github.com/fesplugas/rbenv-installer
curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash

## update .bashrc according to rbenv installer's instruction
# install dependencies
rbenv bootstrap-ubuntu-12-04

# latest ruby 1.9.3-p385
rbenv install 1.9.3-p385
rbenv rehash
rbenv global 1.9.3-p385

# install bundler and rake
gem install bundler --no-ri --no-rdoc
gem install rake --no-ri --no-rdoc
rbenv rehash

# setup git and github or bitbucket or equivalent one!

# remove default nginx config
sudo rm /etc/nginx/sites-enabled/default


# deployment using capistrano && unicorn
# update gemfile

# Deploy with Capistrano
# update Gemfile
## gem 'capistrano'
## gem 'mysql2'
## gem 'unicorn'
## gem 'capistrano'

bundle

# now capify!!
capify .

## update capfile and config/deploy.rb
## add config/nginx.conf
## add unicorn.rb
## add unicorn_init.sh and make it executable
## add delayed job scripts (rails generate delayed_job && capistrano recepies)

## commit the latest changes and update database.yml (youmay want to add it to gitignore file and
## and update it manually on the server, for security reasons, of course)

# Deploying to VPS
cap deploy:setup
cap deploy

# Run Database Migrations
cap deploy:migrate

# for delayed job and sending emails (if you're using)
cap deploy:start

## read this (and comment there) if you need any help : http://blog.sudobits.com/2013/01/07/how-to-deploy-rails-application-to-vps/



4 changes: 2 additions & 2 deletions rails-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ echo "..........Installing Rails gem................"
gem install rails >>$LOG_FILE
echo ".........Done"


echo "######################################"
echo "###### Installation Completed ########"
echo "######################################"

echo "if something went wrong then checkout the log file $LOG_FILE"

echo "if something went wrong then checkout the log file $LOG_FILE"

0 comments on commit 83e1f73

Please sign in to comment.