Ruby is a dynamic, object-oriented programming language best known as the language behind Ruby on Rails, the influential web framework that popularised convention-over-configuration and RESTful web applications. rbenv is the standard Ruby version manager for production servers — it allows installing and switching between multiple Ruby versions per user or per directory, without requiring root access and without modifying system Ruby. rbenv is preferred over RVM in production environments because it is lighter, simpler, and non-invasive (it uses shims rather than modifying shell built-ins). Bundler is Ruby’s dependency manager (equivalent to Composer for PHP or pip for Python), managing gem dependencies via a Gemfile. This guide covers installing rbenv and Ruby 3.3 on RHEL 9, configuring Bundler, and verifying the installation.

Prerequisites

  • RHEL 9 with sudo/root access
  • Development tools: dnf groupinstall -y "Development Tools"

Step 1 — Install Build Dependencies

dnf groupinstall -y "Development Tools"
dnf install -y openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel

Step 2 — Install rbenv

# Install rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv

# Add to PATH
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc

# Install ruby-build plugin (provides 'rbenv install' command)
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

rbenv --version

Step 3 — Install Ruby 3.3

# List available Ruby versions
rbenv install --list | grep "^3."

# Install Ruby 3.3 (compilation takes 5-10 minutes)
rbenv install 3.3.3

# Set as global default
rbenv global 3.3.3

# Verify
ruby --version
gem --version

Step 4 — Configure Bundler (Ruby Dependency Manager)

# Install Bundler
gem install bundler

# Rehash rbenv shims after installing new gems with executables
rbenv rehash

bundler --version

# Configure Bundler to install gems to the project's vendor/bundle
# (avoids root-owned system gems)
bundle config set --local path 'vendor/bundle'

Step 5 — Create a New Ruby Project

mkdir /var/www/myrubyapp && cd /var/www/myrubyapp

# Pin the Ruby version for this project
echo "3.3.3" > .ruby-version

# Create Gemfile
cat > Gemfile < 4.0"
gem "puma", "~> 6.0"
EOF

bundle install

Step 6 — Set Per-Project Ruby Version

# Install multiple versions
rbenv install 3.2.4

# Set local version for a specific project directory
cd /var/www/legacy_app
rbenv local 3.2.4    # Creates .ruby-version file in the directory

# Verify
ruby --version       # Shows 3.2.4 in this directory

Conclusion

rbenv with Ruby 3.3 on RHEL 9 provides a clean, per-user Ruby version management solution. The .ruby-version file in project directories allows teams to pin exact Ruby versions — when anyone runs ruby or bundle in that directory, rbenv automatically uses the pinned version. For Rails or Sinatra applications in production, deploy with Puma (the recommended Ruby application server) and set the number of Puma workers to match the server’s CPU count for maximum throughput.

Next steps: How to Deploy a Ruby on Rails Application on RHEL 9, How to Install Node.js on RHEL 9, and How to Configure Nginx on RHEL 9.