Skip to content

Instantly share code, notes, and snippets.

@sixfeetover
Created January 21, 2011 16:39
Show Gist options
  • Save sixfeetover/789947 to your computer and use it in GitHub Desktop.
Save sixfeetover/789947 to your computer and use it in GitHub Desktop.
Setup ruby/rvm/rails on a fresh ubuntu system
# Log in, change password
passwd
# Add deploy user
adduser deploy
# Add user to sudoers
visudo
# Update apt packages and upgrade installed packages
apt-get update
apt-get -y upgrade
# Install packages
apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion git-core unixodbc unixodbc-dev tdsodbc freetds-dev
# Edit /etc/hosts to add an entry for rs3
# Install rvm
curl -L https://get.rvm.io | sudo bash -s stable
usermod -a -G rvm deploy
# You may need to log out / log back in at this point.
rvm install 1.9.3
rvm use 1.9.3 --default
# APACHE
sudo apt-get install apache2 apache2-prefork-dev libapr1-dev libaprutil1-dev
# PASSENGER
gem install passenger
rvmsudo passenger-install-apache2-module

These parts are manually done

Create the deploy user and add them to sudoers. Syntax: deploy ALL=(ALL) ALL

adduser deploy
visudo

Create nginx start script (/etc/init.d/nginx)

See https://gist.github.com/604841

#!/bin/bash
# Inspired by Josh Frye's https://github.com/joshfng/railsready/blob/master/railsready.sh
# This setup differs in that it uses system-wide RVM and SQLServer instead of system ruby/mysql
shopt -s extglob
set -e
# Check if the user has sudo privileges.
sudo -v >/dev/null 2>&1 || { echo $(whoami) has no sudo privileges ; exit 1; }
echo "Creating install dir..."
cd && mkdir -p railsready/src && cd railsready && touch install.log
echo "done.."
# Update the system before going any further
echo "Updating system..."
sudo apt-get update >> install.log && sudo apt-get -y upgrade >> install.log
echo "done.."
# Install build tools
echo "Installing build tools..."
sudo apt-get -y install \
wget build-essential libxslt1.1 libssl-dev libxslt1-dev libxml2 libffi-dev libyaml-dev libreadline6-dev zlib1g-dev libcurl4-openssl-dev >> install.log
echo "done..."
# Install git-core
echo "Installing git..."
sudo apt-get -y install git-core >> install.log
echo "done..."
# Install necessary libs for SQLServer
sudo apt-get -y install unixodbc unixodbc-dev
# FreeTDS
sudo apt-get -y install tdsodbc freetds-dev
# RVM
bash < <( curl -L http://bit.ly/rvm-install-system-wide )
# add this to /etc/profile: . "/usr/local/rvm/scripts/rvm"
# Add deploy user to the rvm group
usermod -aG rvm reploy
# Log out and log back in as deploy
su deploy
# Install Ruby
echo "Downloading Ruby 1.9.2p136. This will take awhile. Go get coffee."
rvm install 1.9.2
echo "done..."
# Make 1.9.2 the default ruby
rvm use 1.9.2 --default
# Reload bash
echo "Reloading bashrc so ruby and rubygems are available..."
source ~/.bashrc
echo "done..."
echo "Installing Bundler and Passenger..."
sudo gem install bundler passenger --no-ri --no-rdoc
echo "done..."
# Install nginx
mkdir ~/src && cd ~/src
wget http://sysoev.ru/nginx/nginx-0.8.54.tar.gz
tar -xzvf nginx-0.8.54.tar.gz
# I actually do this from the interactive installer, but I think this will give the same result.
# We need to install from source to add the "--with-http_stub_status_module" flags, which is needed by things like munin
rvmsudo passenger-install-nginx-module --nginx-source-dir=/home/deploy/src/nginx-0.8.54 --prefix=/usr/local/nginx --auto --extra-configure-flags="--with-http_stub_status_module"
echo "Installation is complete!"
cd ~/railsready/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment