Home  »  ArticlesGuidesHow ToLibrariesProgrammingSoftwareTechnologyTools   »   How to Install Ruby On Rails on Debian 12 Linux Systems

How to Install Ruby On Rails on Debian 12 Linux Systems

Ruby on Rails, often simply called Rails, is a popular web application framework that provides a robust environment for building dynamic web applications. If you’re using Debian 12 and want to set up Ruby on Rails for your development projects, this guide will walk you through the installation process step-by-step.

Step 1: Update System Packages

Before installing any new software, it’s crucial to ensure that your system packages are up to date. Open a terminal and execute the following commands to update the package repository and installed packages:

$ sudo apt update
$ sudo apt upgrade

This will update the package lists and upgrade all installed packages to their latest versions.

Step 2: Install Ruby

Debian 12 ships with Ruby, but it’s recommended to install the Ruby version manager (rbenv) to manage your Ruby installations. rbenv allows you to install and switch between multiple Ruby versions effortlessly.

Start by installing the necessary dependencies for rbenv and ruby-build (a plugin for rbenv that simplifies the installation of Ruby versions):

$ sudo apt install rbenv ruby-build

After installation, add rbenv to your shell session by appending the following lines to your ~/.bashrc or ~/.zshrc file:

$ export PATH="$HOME/.rbenv/bin:$PATH"
$ eval "$(rbenv init -)"

Then, reload your shell configuration:

$ source ~/.bashrc   # or ~/.zshrc if you use Zsh

Now, you can install a specific version of Ruby. To install the latest stable version, use:

$ rbenv install 3.1.0   # Replace with the desired Ruby version (e.g., 3.1.0)

Set this version as the global default:

$ rbenv global 3.1.0

Verify that Ruby is installed correctly:

$ ruby -v

Step 3: Install Node.js

Rails requires a JavaScript runtime for asset compilation. Install Node.js and npm (Node Package Manager) using the following command:

$ sudo apt install nodejs npm

Verify the installation:

$ node -v
$ npm -v

Step 4: Install Rails

With Ruby and Node.js installed, you can now install Rails using the gem package manager:

$ gem install rails

This command installs the latest stable version of Rails.

Step 5: Verify Rails Installation

After installation, verify that Rails has been installed correctly by checking its version:

$ rails -v

You should see the Rails version number printed to the terminal.

Step 6: Set Up a New Rails Application

To create a new Rails application, navigate to your desired directory and use the following command:

$ rails new myapp

Replace myapp with your preferred application name. This command creates a new Rails application with default settings.

Step 7: Start the Rails Server

Navigate into your newly created Rails application directory:

$ cd myapp

Start the Rails server to see your application in action:

$ rails server

By default, the Rails server will start on http://localhost:3000. Open your web browser and visit this URL to see the default Rails welcome page.


You’ve successfully installed Ruby on Rails on your Debian 12 system and created a new Rails application. From here, you can explore the vast capabilities of Rails and start developing your web projects with ease.

If you encounter any issues or need further customization, refer to the Ruby on Rails Guides for comprehensive documentation and tutorials.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.