How to Install Ruby on Rails on Debian 11

Install Ruby on Rails on Debian 11

In this article, we will have explained the necessary steps to install Ruby on Rails on Debian 11. 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 on Rails, or simply Rails, is a web framework, built with the Ruby programming language, that is used for web application development. There are many well-known applications based on Rails, such as Github, Airbnb, Soundcloud, etc.

Install Ruby on Rails on Debian 11

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

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

Step 2. Install RVM (Ruby Version Manager).

Import the GPG key with the following command:

curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

Then, download and run the installation script:

curl -sSL https://get.rvm.io | bash -s stable --ruby

Once the RVM is installed, load the RVM system path using the following command:

source /usr/local/rvm/scripts/rvm

Verify the Ruby version:

rvm version

Step 3. Install Ruby using RVM.

Now install the latest version of Ruby using the following command below:

rvm install ruby-3.0.3

Next, make the Ruby version the default version using the following command:

rvm --default use ruby-3.0.3

Verify the ruby version by running the following command:

ruby -v

Step 4. Install Node.js and Yarn.

We’re going to install NodeJS and Yarn:

curl -sL https://deb.nodesource.com/setup_16.x | bash -

Then, install the Yarn package manager using the following command:

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

Once upon, update apt and install Node.js and Yarn from the added repositories:

sudo apt update
sudo apt install nodejs yarn

Verify Node.js and Yarn version:

node -v
yarn -v

Step 5. Install Ruby on Rails on the Debian system.

Installing Ruby on Rails on your Debian system is straightforward, Now install the latest version of Ruby on Rails using the RubyGem command:

gem install rails -v 6.1.4

Once the installation is complete, verify the installed version of Rails using the following command:

rails -v

Step 6. Create Project with Ruby on Rails.

Now start your first Rails project with the following command:

rails new linuxtips-app
cd linuxtips-app
rails server -b 0.0.0.0

Step 7. Access Project Ruby on Rails.

Open your web browser and type your server IP address with port ‘3000’ on the address bar to see the Rails default page

Install Ruby on Rails on Debian 11

That’s all you need to do to install Ruby on Rails on Debian (Bullseye). I hope you find this quick tip helpful. For further reading Ruby on Rails open-source web application framework on Debian’s system, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.