Step-by-step Guide: How to Install Ruby on Rails on Debian 12

Learn how to install Ruby on Rails on Debian 12 with this step-by-step guide. Discover the necessary tools, commands, and best practices for a successful installation.

In this article, we will provide you with a comprehensive guide on how to install Ruby on Rails on Debian 12. Ruby on Rails, commonly known as Rails, is a popular open-source web application framework written in Ruby. By following the steps outlined below, you will be able to set up a development environment for Ruby on Rails on your Debian 12 system.

Prerequisites

Before we begin the installation process, ensure that you have the following prerequisites in place:

  1. Debian 12 Installed: Make sure you have a working Debian 12 operating system installed on your machine.
  2. Root Access: You will need root access or a user account with sudo privileges to install packages and make system-wide changes.

Step 1: Update System Packages

The first step is to update the system packages to their latest versions. Open your terminal and execute the following command:

sudo apt update && sudo apt upgrade

This command will update the package lists and upgrade any outdated packages on your Debian 12 system.

Step 2: Install Dependencies

Ruby on Rails requires several dependencies to be installed on your system. Execute the following command to install the necessary packages:

sudo apt install curl gnupg2 dirmngr -y

This command will install the required packages for managing repositories and downloading software.

Step 3: Install Ruby Version Manager (RVM)

RVM is a command-line tool that allows you to easily install, manage, and work with multiple Ruby environments. Execute the following command to install RVM:

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

This command will download and install RVM on your Debian 12 system.

Step 4: Install Ruby

Once RVM is installed, you can use it to install Ruby. Execute the following command to install the latest stable version of Ruby:

rvm install ruby --default

This command will install Ruby and set it as the default version.

Step 5: Install Rails

With Ruby installed, you can now proceed to install Rails. Execute the following command to install the latest version of Rails:

gem install rails

This command will download and install Rails along with its dependencies.

Step 6: Verify Installation

To verify that Ruby on Rails has been successfully installed, execute the following commands:

ruby --version
rails --version

These commands will display the installed versions of Ruby and Rails, respectively.

Step 7: Set Up a New Rails Application

Now that Ruby on Rails is installed, you can create a new Rails application. Execute the following command to generate a new Rails project:

rails new myapp

Replace “myapp” with the desired name of your application.

Step 8: Start the Rails Server

To start the Rails server and access your application through a web browser, navigate to the project directory and execute the following command:

cd myapp
rails server

This command will start the server, and you can access your application by visiting http://localhost:3000 in your web browser.

Conclusion

Congratulations! You have successfully installed Ruby on Rails on Debian 12 and set up a new Rails application. You can now begin developing web applications using the powerful Ruby on Rails framework.

Remember to explore the vast capabilities of Ruby on Rails and refer to the official documentation and online resources for further guidance.

Must Read

Related Articles