How To Set up Ruby on Rails on Debian 11

In this article, we want to teach you How To Set up Ruby on Rails on Debian 11.

Ruby on Rails is software code built on top of Ruby. Technically, it is defined as a package library called RubyGem, installed using the command line interface of the operating system.

Ruby on Rails is an open-source web development framework, which provides Ruby developers a time-saving alternative to developing code. It is a collection of code libraries, which offer a ready-made solution for repetitive tasks like developing tables, forms, or menus on the website.

How To Set up Ruby on Rails on Debian 11

Before you set up Ruby on Rails, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with Debian 11.

Now follow the steps below to install Ruby on Rails on your server.

Install Ruby on Debian 11

First, you need to update your local package index with the following command:

sudo apt update

Then, install the dependencies on your server:

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

Next, you need to install the Ruby version manager (RVM) on Debian 11. Import the GPG key with the command below:

$ curl -sSL | gpg2 --import -
gpg: Total number processed: 1
gpg: imported: 1

Now install the RVM on your server with the command below:

curl -sSL | bash -s stable --ruby

The command will automatically install the packages required, and install the latest stable Ruby version.

To start using the Ruby version manager on Debian 11, run the following command:

source /usr/local/rvm/scripts/rvm

At this point, you can list the available versions of Ruby with the command below:

rvm list known
# MRI Rubies
[ruby-]1.8.7[-head] # security released on head

Then, to install a specific version of Ruby you can use the command:

rvm install <version_number>

Verify your Ruby installation on Debian 11 by checking its version:

ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

Also, you can check the RVM version:

rvm -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

If you want to set the installed version of Ruby as the system default, run the command below:

rvm use --default 3.0.0

Install Rails on Debian 11

At this point, that you have Ruby installed on Debian 11, you can use the command below to install Rails:

gem install rails
35 gems installed

Verify your Rails installation by checking its version:

rails -v

Install Node.js and Yarn on Debian 11

Rails need a Javascript runtime for application development. The simple and easiest way to install Node.js is to install them from the Debian default repository.

First, you need to add the Node.js repository on Debian 11 with the following command:

curl -sL | bash -

Then to install the Yarn package manager, run:

# curl -sL | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
# echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Update your local package index:

sudo apt update

Now you can install Node.js and Yarn on Debian 11:

sudo apt install nodejs yarn

Verify your installations by checking the versions:

node -v
yarn -v

Create a Rails Test Application on Debian 11

At this point, you can start your first Rails project. Here we named it testapp:

rails new testapp

Start your Rails application on Debian 11 with  the following command:

# cd testapp
# rails server -b
=> Booting Puma
=> Rails application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.5.2 (ruby 3.0.0-p0) ("Zawgyi")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 9473
* Listening on
Use Ctrl-C to stop

By now, the Rails application should be running on port 3000.

Now open your web browser and type your server IP address with port ‘3000’ on the address bar.


You will get the default index.html page of Ruby on Rails.


At this point, you learn to Set up Ruby on Rails on Debian 11.

Hope you enjoy it.

Also, you may find the following links useful

Install Ruby on Rails on AlmaLinux 9

Set up Ruby on Rails with rbenv on Ubuntu 22.04

How To Set up Ruby on Rails on Ubuntu 20.04

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!