Home  »  ArticlesGuidesLibrariesProgrammingSoftwareTechnologyTools   »   How to Install Ruby On Rails on Rocky Linux 8.10 Systems

How to Install Ruby On Rails on Rocky Linux 8.10 Systems

Ruby on Rails, often simply called Rails, is a powerful web application framework written in Ruby. It follows the model-view-controller (MVC) architecture and emphasizes convention over configuration. This guide will walk you through the steps to install Ruby on Rails on a Rocky Linux 8.10 system.

Prerequisites

Before starting, ensure you have:

  • A running Rocky Linux 8.10 system
  • A user account with sudo privileges
  • Internet connectivity to download packages

Step 1: Update Your System

Start by updating your system to ensure all existing packages are up to date.

$ sudo dnf update -y

Step 2: Install Dependencies

Install essential development tools and libraries required for building Ruby and other dependencies:

$ sudo dnf groupinstall -y "Development Tools"
$ sudo dnf install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison sqlite-devel

Step 3: Install RVM (Ruby Version Manager)

RVM is a command-line tool which allows you to easily install, manage, and work with multiple Ruby environments.

Add the GPG Key

$ sudo dnf install -y gpg2
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

Install RVM

Install RVM by running the following command:

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

Load RVM into your shell session:

$ source ~/.rvm/scripts/rvm

Step 4: Install Ruby

With RVM installed, you can now install Ruby. For this guide, we’ll install the latest stable version of Ruby.

$ rvm install 3.1.2
$ rvm use 3.1.2 --default

Verify the Ruby installation:

$ ruby -v

You should see output similar to:

ruby 3.1.2p0 (2022-04-12 revision 0) [x86_64-linux]

Step 5: Install Node.js and Yarn

Rails uses Node.js for the Asset Pipeline, and Yarn is used to manage JavaScript dependencies.

Install Node.js

$ sudo dnf install -y nodejs

Install Yarn

Add the Yarn repository and install Yarn:

$ curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
$ sudo dnf install -y yarn

Step 6: Install Rails

Finally, install Rails using the gem package manager:

$ gem install rails -v 7.0.3

Verify the Rails installation:

$ rails -v

You should see output similar to:

Rails 7.0.3

Step 7: Set Up a New Rails Application

To ensure everything is working correctly, create a new Rails application. Navigate to the directory where you want to create your application and run:

$ rails new myapp
$ cd myapp

Step 8: Start the Rails Server

Start the Rails server to make sure your application is running correctly:

$ rails server

Open a web browser and navigate to http://localhost:3000. You should see the Rails welcome page, indicating that everything is set up correctly.

Conclusion

You have successfully installed Ruby on Rails on your Rocky Linux 8.10 system. This powerful framework is now ready for you to start developing web applications. For more detailed configurations and optimizations, refer to the official documentation of each component:

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