Skip to content

Instantly share code, notes, and snippets.

@yuriihabrusiev
Created November 7, 2013 15:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuriihabrusiev/7356212 to your computer and use it in GitHub Desktop.
Save yuriihabrusiev/7356212 to your computer and use it in GitHub Desktop.
Installing Ruby with rbenv on development and production boxes
#!/bin/bash
#
# Local Ruby with rbenv and ruby-build
## Update apt
sudo apt-get -y update
## Install git and curl
echo " ### INSTALLING GIT AND CURL ###"
sudo apt-get install -y git curl
## Install dependencies for building Rubies
echo " ### INSTALLING RUBY-BUILD DEPENDENCIES ###"
sudo apt-get install -y build-essential autoconf libssl-dev libyaml-dev libreadline6 libreadline6-dev zlib1g zlib1g-dev
## Install rbenv and ruby-build
echo " ### INSTALLING RBENV AND RUBY-BUILD ###"
RBENV_ROOT="$HOME/.rbenv"
git clone https://github.com/sstephenson/rbenv.git $RBENV_ROOT
git clone https://github.com/sstephenson/ruby-build.git $RBENV_ROOT/plugins/ruby-build
# Add rbenv to the path
echo '# rbenv setup' >> ~/.bashrc
echo 'export RBENV_ROOT=$HOME/.rbenv' >> ~/.bashrc
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
## Install Ruby and set as global Ruby
echo " ### INSTALLING RUBY ###"
RUBY="2.0.0-p247"
rbenv install $RUBY
rbenv global $RUBY
rbenv rehash
## Install Bundler
echo " ### INSTALLING BUNDLER ###"
gem install bundler
rbenv rehash
#!/bin/bash
#
# System-wide Ruby with rbenv and ruby-build
## Update apt
apt-get -y update
## Install git and curl
echo " ### INSTALLING GIT AND CURL ###"
apt-get install -y git curl
## Install dependencies for building Rubies
echo " ### INSTALLING RUBY-BUILD DEPENDENCIES ###"
apt-get install -y build-essential autoconf libssl-dev libyaml-dev libreadline6 libreadline6-dev zlib1g zlib1g-dev
## Install rbenv and ruby-build
echo " ### INSTALLING RBENV AND RUBY-BUILD ###"
RBENV_ROOT="/usr/local/rbenv"
git clone https://github.com/sstephenson/rbenv.git $RBENV_ROOT
git clone https://github.com/sstephenson/ruby-build.git $RBENV_ROOT/plugins/ruby-build
# Add rbenv to the path
echo '# rbenv setup' > /etc/profile.d/rbenv.sh
echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
chmod +x /etc/profile.d/rbenv.sh
source /etc/profile.d/rbenv.sh
## Install Ruby and set as global Ruby
echo " ### INSTALLING RUBY ###"
RUBY="2.0.0-p247"
rbenv install $RUBY
rbenv global $RUBY
rbenv rehash
## Disable ri and rdoc
echo "install: --no-document" > /etc/gemrc
echo "update: --no-document" >> /etc/gemrc
cp /etc/gemrc /root/.gemrc
cp /etc/gemrc /etc/skel/.gemrc
## Install Bundler
echo " ### INSTALLING BUNDLER ###"
gem install bundler
rbenv rehash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment