Install ruby 1.9.3-p125 from source

March 02, 2012

On ubuntu server 10.04 you might want to avoid rvm and rbenv and just go straight for installing ruby on your server.

Install openssl development libraries and prerequisites.

sudo apt-get -y install build-essential libssl-dev libreadline5-dev zlib1g-dev

Install yaml

#!/bin/bash

cd /usr/src
sudo wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
sudo tar xvzf yaml-0.1.4.tar.gz
cd yaml-0.1.4
sudo ./configure --prefix=/usr/local
sudo make 
sudo make install

Install ruby

#!/bin/bash

cd /usr/src
sudo wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
sudo tar xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
sudo ./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib --with-openssl-dir=/usr --with-readline-dir=/usr --with-zlib-dir=/usr
sudo make
sudo make install

Install rubygems

  !#/bin/bash

  cd /usr/src 
  sudo wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.17.tgz
  sudo tar xvzf rubygems-1.8.17.tgz
  cd rubygems-1.8.17
  sudo ruby setup.rb  

This is applicable if you want to run a certain version of ruby globally on your production server. If there is alreadt a version of ruby installed, check /usr/bin/ruby, /usr/bin/gem and /usr/bin/bundle and update the links accordingly.

eg.

  sudo rm /usr/bin/ruby; sudo ln -s /usr/local/bin/ruby /usr/bin/ruby
  sudo rm /usr/bin/gem; sudo ln -s /usr/local/bin/gem /usr/bin/gem
  sudo gem install bundler --pre
  sudo rm /usr/bin/bundle; sudo ln -s /usr/local/bin/bundle /usr/bin/bundle

Happy compiling!