It can consume a lot of time setting up servers for projects that unfortunately still use older versions of Ruby. Thankfully, there are Ruby version managers like RVM and rbenv that make the job a lot easier for us.
This short guide is for installing Ruby 1.8.7 in Ubuntu 20.04 using RVM.
Install RVM
RVM has different installation modes that affect whether the Ruby versions and Ruby gems installed are available system-wide or only for a particular user. To install RVM system-wide, you only need to perform the installation as root (or with sudo). Otherwise, you can run the installation as a normal user.
To install, first you need to import the GPG keys that the RVM installer will use to verify the package it downloads. Please check the RVM website for the updated GPG keys.
gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
You may now install RVM.
curl -sSL https://get.rvm.io | bash -s stable
Install libssl1.0-dev
The libssl1.0-dev package is an old package which Ruby 1.8.7 requires. However, this is no longer available in recent versions of Ubuntu.
You can still install this package from the Ubuntu 18.04 (Bionic Beaver) repository. To do this, first you need to add the source to apt’s list of repositories. Edit /etc/apt/sources.list and add the following line:
deb http://security.ubuntu.com/ubuntu/ bionic-updates main
The GPG key for the apt repository also needs to be imported for verification purposes:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3B4FE6ACC0B21F32
Once that is done, you can proceed to install libssl1.0-dev:
sudo apt update
sudo apt install libssl1.0-dev
Install other necessary packages
Then, install all the necessary compiler packages and library dependencies for Ruby compilation:
sudo apt install g++ gcc autoconf automake bison libc6-dev libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev libreadline-dev
Install Ruby 1.8.7
Finally, load RVM into your shell and install Ruby 1.8.7:
source /etc/profile
rvm install 1.8.7