08.21.2019

Install Ruby using rbenv on Ubuntu 18.04

This guide will show how to install Ruby using rbenv. Current version is ruby 2.5.1

We should install Ruby using user account (should not use root account for this action)

Accessing server with root permisson

Add new user account

useradd -m ubuntu

passwd ubuntu

su ubuntu

cd

exec bash

new we are accessing serser using user account

Make sure you were install git, gcc, make, libssl-dev libreadline-dev zlib1g-dev on your server, if not, run as root permission

apt install git gcc make

apt-get install -y libssl-dev libreadline-dev zlib1g-dev

Now we start install rbenv:

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
# Restart shell
exec bash
# Check if rbenv is correctly installed
type rbenv
# Install ruby-build as rbenv plugin
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

We can check for latest version of Ruby here https://www.ruby-lang.org/en/downloads/

Then we will install latest version of Ruby (current: 2.5.1)

rbenv install 2.5.1
rbenv global 2.5.1

Happy coding

Leave a comment