Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Rails stack installation

DimaSamodurov edited this page Jul 22, 2011 · 9 revisions

This happens immediately as you have installed OS

adduser dima
visudo 
#dima   ALL=(ALL) ALL

#locally
scp ~/.ssh/id_rsa.pub dima@173.203.56.180:id_rsa.pub
mkdir /home/dima/.ssh
mv /home/dima/id_rsa.pub /home/dima/.ssh/authorized_keys

chown -R dima:dima /home/dima/.ssh ; chmod 700 /home/dima/.ssh ; chmod 600 /home/dima/.ssh/authorized_keys

nano /etc/ssh/sshd_config
PermitRootLogin no
PasswordAuthentication no
AllowUsers dimo

scp .bashrc dima@orvabud:.
scp .gemrc dima@orvabud:.
scp .profile dima@orvabud:.
scp .gitconfig dima@orvabud:.

source .bashrc

#source list
sudo nano /etc/apt/sources.list

sudo locale-gen uk_UA.UTF-8
sudo /usr/sbin/update-locale LANG=uk_UA.UTF-8
sudo aptitude safe-upgrade
#read more https://help.ubuntu.com/community/Locale

sudo /usr/sbin/update-locale LANG=en_US.UTF-8

chsh -s /bin/bash dima 
ln -s .bashrc .bash_profile

Generate SSH key

ssh-keygen -t rsa -C "dimasamodurov@orvabud.com"
cat ~/.ssh/id_rsa.pub
# put to github

Install git

apt-get install git-core
git config --global user.name "Dima Samodurov"
git config --global user.email "dimasamodurov@gmail.com"

The steps listed above show you how to set your user info globally. This means that no matter which repo you work in on your computer, you’ll be making commits as that user. If you find yourself needing to make commits with different user info for a specific repo (perhaps for work vs. personal projects), you will have to change the info in that repo itself.

$ cd my_other_repo    
$ git config user.name "Dima Samodurov"
$ git config user.email "dimasamodurov@gmail.com"
$ git config github.token 22ef6c5135257c057f005395279ef093

git config --global github.token 22ef6c5135257c057f005395279ef093
ssh -T git@github.com

Install RVM

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

Ruby

aptitude install build-essential bison openssl libreadline5 libreadline5-dev curl git-core zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libmysqlclient-dev
rvm install 1.9.2
rvm use 1.9.2 --default
sudo apt-get install libcurl4-openssl-dev
rvmsudo passenger-install-nginx-module
#choose 1
#Modify /opt/nginx/conf/nginx.conf (thats the default location).
#passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.2-p290/ruby; #no necessary andy more

Deploying a Ruby on Rails application: an example

Suppose you have a Ruby on Rails application in /somewhere. Add a server block to your Nginx configuration file, set its root to /somewhere/public, and set 'passenger_enabled on', like this:

server {
  listen 80;
  server_name www.orvabud.com;
  root /var/www/orvabud/current/public;   # <--- be sure to point to 'public'!
  passenger_enabled on;
}

And that's it! You may also want to check the Users Guide for security and optimization tips and other useful information:

/usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.7/doc/Users guide Nginx.html

Next steps:

mkdir orvabud
cd orvabud
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:DimaSamodurov/orvabud.git
git push -u origin master

Existing Git Repo?

cd existing_git_repo
git remote add origin git@github.com:DimaSamodurov/orvabud.git
git push -u origin master
cap deploy:setup
cap deploy
cd
git clone git://github.com/jnstq/rails-nginx-passenger-ubuntu.git
sudo mv rails-nginx-passenger-ubuntu/nginx/nginx /etc/init.d/nginx
sudo chown root:root /etc/init.d/nginx

Verify that you can start and stop nginx with init script

sudo /etc/init.d/nginx start

  * Starting Nginx Server...
  ...done.

sudo /etc/init.d/nginx status

  nginx found running with processes:  11511 11510

sudo /etc/init.d/nginx stop

  * Stopping Nginx Server...
  ...done.

sudo /usr/sbin/update-rc.d -f nginx defaults    

ImageMagick

sudo apt-get install libperl-dev gcc libjpeg62-dev libbz2-dev libtiff4-dev libwmf-dev libz-dev libpng12-dev libx11-dev libxt-dev libxext-dev libxml2-dev libfreetype6-dev liblcms1-dev libexif-dev perl libjasper-dev libltdl3-dev graphviz gs-gpl pkg-config

sudo apt-get install imagemagick

Project Git configuration

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@github.com:DimaSamodurov/orvabud.git
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "deploy"]
        remote = origin
        merge = refs/heads/master

Or

$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/maste