DEV Community

Cover image for Installing an Outdated Ruby Version on a Linux Server
Matthew LaFalce
Matthew LaFalce

Posted on

Installing an Outdated Ruby Version on a Linux Server

Whether you're working on a legacy Rails app or debugging an old script, there are times when you need to install a specific (and sometimes outdated) version of Ruby on a Linux server. Ruby 2.7.0, released back in late 2019, is no longer supported by many modern environments, but it's still used in older projects.

In this guide, I’ll walk through installing Ruby 2.7.0 from source on a Linux machine. This process avoids version managers like RVM or rbenv, and instead gives you full control over where Ruby is installed.


⚠️ Why Install from Source?

Installing from source is helpful when:

  • You want Ruby in a custom directory like /opt/rubies/2.7.0.
  • You’re on a minimal server without a version manager.
  • You need a very specific Ruby version, not available in your OS's package manager.

🛠️ Prerequisites

Make sure your system has the required build tools and libraries installed. On Debian/Ubuntu systems:

sudo apt update
sudo apt install -y build-essential libssl-dev libreadline-dev zlib1g-dev
Enter fullscreen mode Exit fullscreen mode

On RHEL/CentOS:

sudo yum groupinstall "Development Tools"
sudo yum install -y openssl-devel readline-devel zlib-devel
Enter fullscreen mode Exit fullscreen mode

📦 Step-by-Step: Installing Ruby 2.7.0

Here’s a shell script to automate the process:

#!/bin/bash

# Download Ruby 2.7.0
wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0.tar.gz

# Extract the archive
tar -xzvf ruby-2.7.0.tar.gz ruby-2.7.0/

# Move into the directory
cd ruby-2.7.0/

# Configure the installation path
./configure --prefix=/opt/rubies/2.7.0

# Compile the source (this may take several minutes)
make

# Install (use sudo if installing outside your home directory)
sudo make install

# Clean up
cd ..
rm -rf ruby-2.7.0 ruby-2.7.0.tar.gz
Enter fullscreen mode Exit fullscreen mode

📍 Verifying the Installation

After installation, make sure the correct Ruby version is in your PATH:

export PATH="/opt/rubies/2.7.0/bin:$PATH"
Enter fullscreen mode Exit fullscreen mode

You can add that line to your .bashrc or .zshrc file for it to persist.

Now check:

ruby -v
# => ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
Enter fullscreen mode Exit fullscreen mode

🧹 Pro Tip: Avoid System-Wide Installs

It’s generally a good idea to install older Ruby versions into isolated directories like /opt/rubies/2.7.0 rather than using sudo make install into /usr/local. This keeps things cleaner, avoids version conflicts, and allows you to uninstall Ruby by just removing that folder.


🔚 Wrapping Up

Manually installing Ruby may feel old-school, but it’s reliable and gives you flexibility—especially on servers where you want minimal dependencies. Ruby 2.7.0 is still a capable version, but remember: it reached end-of-life in March 2023, so use it only when necessary and try to upgrade your apps when possible.


📚 References

Top comments (0)