In this article, we will have explained the necessary steps to install and configure Ruby on Ubuntu 18.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
Ruby is a dynamic, open-source programming language behind Ruby on Rails framework. It is especially appealing to beginners because of its highly readable and clear syntax, allowing users to develop faster and more efficiently.
Install Ruby on Ubuntu
Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.
sudo apt update sudo apt upgrade
Step 2. Install Ruby.
- Install Ruby using Rbenv:
sudo apt update sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev
Next, run the following curl command to install both rbenv and ruby-build:
curl -sL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash -
Before starting using rbenv we need to add $HOME/.rbenv/bin to our PATH:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc source ~/.bashrc
The current latest stable version for Ruby is 2.6.1 at the time of writing this tutorial. Run below command to install Ruby:
rbenv install 2.6.1 rbenv global 2.6.1
You should confirm the installation and check the version of Ruby using below command:
ruby -v
- Install Ruby from Ubuntu Repositories.
apt update
Start the Ruby installation process by running the command:
sudo apt install ruby-full
To verify that the installation it was successful run the following command which will print the Ruby version:
ruby --version
That’s all you need to do to install Ruby on Ubuntu 18.04 Bionic Beaver. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.