Installing Ruby 1.8.7 on Ubuntu 14.04

Table of Content

When you install ruby, the version would be 1.9 by default. It is rather tough to install ruby 1.8.7. See the information for installing ruby 1.8.7.
[cc]
$ cd ~
$ sudo apt-get install git-core
$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
[/cc]
Restart your shell and check:
[cc]
$ type rbenv
[/cc]
Install necessary programs before installing ruby:
[cc]
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
$ sudo apt-get install subversion libapache2-svn apache2-utils
$ sudo apt-get install autoconf
$ sudo apt-get install bison
[/cc]
Now you can check available versions of ruby:
[cc]
$ rbenv install --list
[/cc]
For installing version 1.8.7-p375:
[cc]
$ rbenv install 1.8.7-p375
$ rbenv rehash
[/cc]
After installing ruby, "rbenv rehash" should be done.
Now you can test whether version 1.8.7-p375 is correctly installed:
[cc]
$ ruby -v
[/cc]
You can check the versions currently installed on your system:
[cc]
$ rbenv versions
[/cc]
You can set the global version:
[cc]
$ rbenv global 1.8.7-p375
[/cc]
You can set a local version on each directory and thus you can select a version on each directory:
[cc]
$ mkdir hoge
$ cd hoge
$ rbenv local 2.1.4
[/cc]