Skip to content

Instantly share code, notes, and snippets.

@chriskottom
Created October 7, 2010 16:54
Show Gist options
  • Save chriskottom/615443 to your computer and use it in GitHub Desktop.
Save chriskottom/615443 to your computer and use it in GitHub Desktop.
Bash script to install Ruby with RVM and selected dependencies on my system
#!/bin/bash
#
# ruby_install.sh
# A simple Bash script for building up my Ruby development environment on a clean system.
# The configuration used is the one that I like.
# - Base system Ruby = version 1.9.2
# - Ruby installed from source
# - Installation of RVM + Rubies
# - Configuration of gemset for local instance of Passenger
#
#
# Script variables
#
WORKING_DIR=/tmp
RUBY_MAJOR=1.9
RUBY_MINOR=2
RUBY_PATCH=0
RUBY_VERSION=$RUBY_MAJOR.$RUBY_MINOR-p$RUBY_PATCH
RUBY_SOURCE=ruby-$RUBY_VERSION
RUBY_URL=ftp://ftp.ruby-lang.org/pub/ruby/$RUBY_MAJOR/$RUBY_SOURCE.tar.gz
PREFIX=/usr/local
RVM_RUBIES=( 1.8.7 1.9.1 1.9.2 ree rbx jruby )
DEFAULT_RUBY=1.9.2
#
# Install base Ruby
#
cd $WORKING_DIR
wget $RUBY_URL
sudo rm -rf $RUBY_SOURCE
tar xzf $RUBY_SOURCE.tar.gz
cd $RUBY_SOURCE
autoconf
./configure --prefix=$PREFIX
make
sudo make install
#
# Install RVM with SSL support
#
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
if grep -q ".rvm/scripts/rvm" "~/.bash_profile" ; then
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >> ~/.bash_profile
echo '[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion' >> .bash_profile
fi
source ~/.rvm/scripts/rvm
rvm package install openssl
rvm package install zlib
rvm package install readlib
#
# Install Rubies for RVM
#
for ruby in ${RVM_RUBIES[@]}; do
if [[ $ruby =~ ^rbx ]]; then
rvm install $ruby
else
rvm install $ruby -C --with-openssl-dir=$HOME/.rvm/usr --with-zlib-dir=$HOME/.rvm/usr --with-readline-dir=$HOME/.rvm/usr
fi
done
rvm --default $DEFAULT_RUBY
#
# Set up support for running Passenger under REE.
# Rack will live within the global gemset
#
rvm ree@global
gem install rack
rvm gemset create passenger
rvm ree@passenger
gem install passenger --pre # version 3.0 is still in beta...
passenger-install-apache2-module --auto
echo
echo "Configuration of Apache server left as an exercise for the user..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment