Ruby on Rails is a popular web development framework that is written in the Ruby programming language. In this article, we will guide you through the process of installing Ruby on Rails on Ubuntu 20.04 using the rbenv tool.
Before we begin, make sure that you have a fresh installation of Ubuntu 20.04 and that the necessary dependencies are installed on your system. You will also need to be logged in as a user with sudo privileges.
Install rbenv
The first step is to install rbenv
, which is a tool that allows you to manage multiple versions of Ruby on your system. To install rbenv
, run the following ommands in the terminal:
Copy code
sudo apt update
sudo apt install git
git clone <https://github.com/rbenv/rbenv.git> ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
This will clone the rbenv
repository, add the necessary configuration to your bashrc
file, and activate the changes.
Install Ruby-build
After installing rbenv
, we need to install the Ruby-build plugin, which allows you to easily install and compile different versions of Ruby. To install Ruby-build, run the following commands in the terminal:
git clone <https://github.com/rbenv/ruby-build.git> ~/.rbenv/plugins/ruby-build
This will clone the Ruby-build repository to the rbenv
plugins directory.
Install Ruby
After installing rbenv
and Ruby-build, we can use the rbenv
tool to install Ruby on our system. To do this, run the following commands in the terminal:
rbenv install 2.7.2
rbenv global 2.7.2
This will install Ruby 2.7.2 on your system and set it as the default version of Ruby. You can verify the installed version of Ruby by running the following command:
ruby -v
Install Bundler
After installing Ruby, we need to install the Bundler gem, which is a tool that allows you to manage the dependencies for your Ruby on Rails application. To install Bundler, run the following command in the terminal:
gem install bundler
This will install the Bundler gem on your system.
Install Rails
After installing Bundler, we can use it to install the Rails gem, which is the core gem for the Ruby on Rails framework. To do this, run the following command in the terminal:
gem install rails
This will install the Rails gem on your system. You can verify the installed version of Rails by running the following command:
rails -v
By following these steps, you should have successfully installed Ruby on Rails on your Ubuntu 20.04 system using the rbenv
tool. You can now use Ruby on Rails to develop web applications.