How to Install Ruby on Rails on Debian 11

Hello, friends. In this post, you will learn how to install Ruby on Rails on Debian 11. This tutorial is important because many novice users don’t know how to get this framework.

What is Ruby on Rails?

Ruby on Rails, or simply Rails, is a web framework, built with the Ruby programming language, that is used for web application development.

Rails is created with some philosophical principles such as

  • Dry stands for “Don’t Repeat Yourself” and refers to avoid writing the same code over and over again.
  • Convention on configuration to speed up the creation of applications.
  • MVC architecture for application logic.

So, Rails is a solid alternative for creating complete and functional web applications.

Let’s get started.

Install Ruby on Debian 11

In this tutorial, we will run the commands as root user. So, open a terminal and refresh the system.

apt update
apt upgrade

The easiest way to install Ruby is to do it using RVM, which is a tool that allows us to install Ruby versions on the system.

To complete this, it installs some necessary packages

apt install apt-transport-https ca-certificates gnupg2 curl

Now download the GPG key to install RVM

curl -sSL | gpg2 --import -

Now download and run the installation script

curl -sSL | bash -s stable --ruby

At the end of the process, RVM will be installed on the system. To use it first run

source /usr/local/rvm/scripts/rvm

And update it to its latest version

rvm get stable --autolibs=enable

Then, install the 3.0.2 version of Ruby, which is very stable.

rvm install ruby-3.0.2

Make sure it is the default version.

rvm --default use ruby-3.0.2

And verify the changes by checking the Ruby version

ruby -v
ruby 3.0.2p107 (2020-07-07 revision 0db68f0233) [x86_64-linux]
1.- Ruby version on Debian 11
1.- Ruby version on Debian 11

Install Ruby on Rails on Debian 11

Now you can install Ruby on Rails on Debian 11. In my case, I have chosen 6.1.4 which has never given any problems.

gem install rails -v 6.1.4

At the end of the process, you will be able to check the installed version

rails -v
Rails 6.1.4

Now we have to install NodeJS and Yarn.

Install NodeJS and Yarn on Debian 11

Rails needs JavaScript to render the view. That’s why we’re going to install NodeJS and Yarn in their updated versions.

Add the NodeJS repository

curl -sL | bash -

Now add the GPG key from the Yarn repository

curl -sL | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null

After this, add the Yarn repository

echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Now install NodeJS and Yarn

apt update
apt install nodejs yarn

Verify NodeJS version

node -v

And the Yarn

yarn -v

Now we can create a project with Rails.

Create a new project with Ruby on Rails

Create a new project using the rails command.

rails new example

Replace example with the name of your project.

Access the generated folder

cd example

And serve the project

rails s -b -p 3000
2.- Serve the project with Ruby on Rails
2.- Serve the project with Ruby on Rails

Open a web browser and go to http://ip-pc:3000 and you will see the following

3.- Ruby on Rails on Debian 11
3.- Ruby on Rails on Debian 11

So, Ruby on Rails is ready for battle.


Ruby on Rails is a complete framework that allows us to develop web applications with all the power of Ruby. So, enjoy it.

I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook