Skip to content

Instantly share code, notes, and snippets.

@dillera
Created February 10, 2012 20:44
Show Gist options
  • Save dillera/1792715 to your computer and use it in GitHub Desktop.
Save dillera/1792715 to your computer and use it in GitHub Desktop.
Install Ruby with rbenv/ruby-build on Centos6 with openssl
#!/bin/bash
set -e # exit on error
### README
# * installs your desired ruby versions using rbenv
# ** including openssl (needed by bundler)
# ** including sqlite (probably needed for rails apps)
#
# Before you start:
# * put ssh-keys in place
# * $ ssh [email protected]
# * If you're behind a proxy, be sure to set $http_proxy etc!
#
# After the Script has run:
# * reload your .bash_profile
### /README
### CONFIG
# Ruby Versions to install
RBVER192='1.9.2-p290'
RBVER187='1.8.7-p357'
RBVER193='1.9.3-p125'
RBVER_GLOBAL=${RBVER192}
PROFILE=~/.bash_profile
MYPROXY="http://proxy:3128"
### /CONFIG
# install some dependancies (requires root)
sudo yum groupinstall -y "Development tools"
sudo yum -y install sqlite-devel sqlite openssl openssl-devel readline-devel readline compat-readline5 libxml2-devel libxslt-devel libcurl curl wget git
#
#
# Deal with an HTTP Proxy
git config --global http.proxy $MYPROXY
git config --global http.sslverify false
sudo sh -c 'echo "proxy=${MYPROXY}" >> /etc/wgetrc'
sudo sh -c 'echo "proxy=${MYPROXY}" >> /etc/yum.conf'
echo "proxy=${MYPROXY}" >> ~/.curlrc
echo "http-proxy: ${MYPROXY}" >> ~/.gemrc
echo insecure >> ~/.curlrc
cd
### Install rbenv, setup your profile of choice
test -d ~/.rbenv || git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
# modify $PATH and autoload rbenv
grep 'rbenv/bin' $PROFILE &>/dev/null || echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $PROFILE
grep 'rbenv init' $PROFILE &>/dev/null || echo 'eval "$(rbenv init -)"' >> $PROFILE
grep 'unset RUBYLIB' $PROFILE &>/dev/null || echo 'unset RUBYLIB' >> $PROFILE
# reload shell
source $PROFILE
### Install ruby-build
test -d ~/ruby-build || git clone https://github.com/sstephenson/ruby-build.git ~/ruby-build
cd ~/ruby-build && sudo ./install.sh
### Install Rubies, 1.8.7, 1.9.2, 1.9.3
rbenv install $RBVER192 --with-openssl-dir=/usr/lib64
rbenv install $RBVER187 --with-openssl-dir=/usr/lib64
rbenv install $RBVER193 --with-openssl-dir=/usr/lib64
# reload binaries
rbenv rehash
# set as default version
rbenv global $RBVER_GLOBAL
ruby -v
# set some defaults
test -s ~/.gemrc || echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc
echo 'Here is your ~/.gemrc:'
cat ~/.gemrc
echo '=== end of .gemrc ==='
# reload shell
source $PROFILE
# install some gems that you love
gem install actionmailer -v=2.3.8
gem install actionpack -v=2.3.8
gem install activesupport -v=2.3.8
gem install highline -v=1.6.1
gem install json -v=1.6.5
gem install mime-types -v=1.16
gem install nokogiri -v=1.4.3.1
gem install rest-client -v=1.6.1
gem install bundler i18n capistrano
rbenv rehash
grep 'BUNDLE_WITHOUT' $PROFILE &>/dev/null || echo 'export BUNDLE_WITHOUT=production' >> $PROFILE
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment