How to Install Ruby on Rails on AlmaLinux
Learn about Ruby on Rails with this overview and the steps to install Ruby on Rails on AlmaLinux. You'll also learn how to develop and test a new Rails application using a web browser. Ruby on Rails is a popular, free, open-source development framework for building web applications in the Ruby programming language.
Rail is a server-side framework for building web applications that makes it easier to leverage web standards, like JSON or XML for data transport, and HTML, CSS, and JavaScript for the user interface. If you happen to still be on CentOS 8, you can also read about installing Ruby on Rails on CentOS 8 in our knowledge base.
Prerequisites
- Operating System and Version: AlmaLinux OS 8.
- Access to the AlmaLinux OS 8 system as a user root using the sudo command — or a user with admin privileges.
About AlmaLinux OS 8 and AlmaLinux OS 9 at Liquid Web
Refer to the official AlmaLinux Release Notes page for a better understanding of the features and support for AlmaLinux 8 and AlmaLinux 9. At the date of this article's publication, Liquid Web does not offer AlmaLinux 9 servers, only AlmaLinux 8 servers. Although this scenario may change in the future, this tutorial is focused on the steps involved for an install of Ruby on Rails on AlmaLinux 8. If your server is running AlmaLinux 9, you would need to research the equivalent installation steps for that version of AlmaLinux.
Install Ruby on Rails on AlmaLinux
Install Ruby on Rails on AlmaLinux - Part 1: Update Your AlmaLinux System
You can update your AlmaLinux system by executing the below command:
~]# sudo dnf update -y
Then, install the required packages by executing the below command:
~]# sudo yum install -y git gnupg2 git-core zlib zlib-devel gcc-c++ patch readline readline-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl tar sqlite-devel
Install Ruby on Rails on AlmaLinux - Part 2: Choose Install Option & Complete Installation
You can install Ruby on Rails on your AlmaLinux system in the following ways:
- Option 2a: Using AppStream Repository
- Option 2b: Using Ruby Version Manager (RVM)
- Option 2c: Using rbenv
Option 2a: Install Ruby using AppStream Repository
Step 1: Install Ruby Using AppStream
Ruby is available in the AlmaLinux AppStream repository and can be installed by executing the below command:
~]# sudo dnf install ruby ruby-devel
Step 2: Check Ruby Version
Once the installation is complete, execute the command below to check the Ruby version:
~]# ruby --version
Here is the output:
[root@ruby-almalinux8 ~]#~]# ruby --version
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-linux]
Option 2b: Install Ruby Using RVM
Ruby Version Manager (RVM) is a versatile command line interface (CLI) utility that simplifies the installation and management of Ruby environments. Using the steps provided, you can install Ruby on Rails using RVM.
Step 1: Install RVM Startup Script
You can download and install the RVM startup script by executing the following commands:
~]# curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
~]# curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
~]# sudo dnf -y install tar
~]# curl -sSL https://get.rvm.io | bash -s stable
Step 2: Update System Environment
You can update the system environment by executing the command below:
~]# source /etc/profile.d/rvm.sh
Step 3: Reload RVM
To reload RVM, execute the below command:
~]# rvm reload
Here is the output:
[root@ruby-almalinux8 ~]# rvm reload
RVM reloaded!
Step 4: Install Required Packages
To install the required packages, execute the below command:
~]# rvm requirements
Step 5: List Installable Versions
Execute this command to list the installable versions:
~]# rvm list known
Step 6: Install Ruby
You can install the preferred version of Ruby by executing the below command. Please replace with the specific Ruby version as per your requirements:
rvm install ruby <version>
Step 7: Check Ruby Version
Once the installation is complete, execute the command below to check the Ruby version:
~]# ruby --version
Here is the output:
[root@ruby-almalinux8 ~]#~]# ruby --version
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-linux]
Option 2c: Install Ruby Using rbenv
The rbenv tool is a command-line utility that allows you to move between installed Ruby versions. Using these steps, you are able to install Ruby on Rails using rbenv.
Step 1: Download Updates and Dependencies
You can download updates and dependencies by executing the below commands:
~]# sudo dnf update
~]# sudo dnf -y install git
Step 2: Clone rbenv and Set PATH
To clone rbenv with git and set PATH variables, execute the below commands:
~]# git clone https://github.com/rbenv/rbenv.git .rbenv
~]# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
~]# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
Here is the output:
[root@ruby-almalinux8 ~]# git clone https://github.com/rbenv/rbenv.git .rbenv
Cloning into '.rbenv'...
remote: Enumerating objects: 3194, done.
remote: Counting objects: 100% (344/344), done.
remote: Compressing objects: 100% (200/200), done.
remote: Total 3194 (delta 192), reused 260 (delta 132), pack-reused 2850
Receiving objects: 100% (3194/3194), 643.89 KiB | 6.13 MiB/s, done.
Resolving deltas: 100% (1982/1982), done.
[root@ruby-almalinux8 ~]# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
[root@ruby-almalinux8 ~]# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
Step 3: Clone Ruby-Build and Set PATH
To clone ruby-build with git and set the PATH variables, execute the below commands:
~]# git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
~]# echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
~]# source ~/.bash_profile
Here is the output:
[root@ruby-almalinux8 ~]# git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Cloning into '/root/.rbenv/plugins/ruby-build'...
remote: Enumerating objects: 13992, done.
remote: Counting objects: 100% (142/142), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 13992 (delta 88), reused 129 (delta 83), pack-reused 13850
Receiving objects: 100% (13992/13992), 2.79 MiB | 11.30 MiB/s, done.
Resolving deltas: 100% (9570/9570), done.
[root@ruby-almalinux8 ~]# echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
[root@ruby-almalinux8 ~]# source ~/.bash_profile
Step 4: List Available Versions of Ruby
Listing the available versions of Ruby is done by executing the below command:
~]# rbenv install -l
Only the most recent stable releases of each Ruby implementation are displayed.
You can also use either of the below commands rbenv install --list-all or rbenv install -L to show all local versions:
~]# rbenv install --list-all
or
~]# rbenv install -L
Step 5: Install Ruby
You can now install the preferred Ruby version by executing the below command. Please replace with the Ruby version as per your requirements:
~]# rbenv install -v <version>
~]# rbenv rehash
Step 6: Check Ruby Version
Once the installation is complete, execute the command below to check the Ruby version:
~]# rbenv versions
Here is the output:
~]# rbenv install -v 2.5.9
~]# rbenv rehash
[root@ruby-almalinux8 ~]# rbenv versions
* system
2.5.9
The Ruby installation fails if the /tmp partitions are mounted as noexec (meaning that it cannot hold executables). There are two options to get around this.
The first would be to edit the build file and change the location of TMPDIR.
The second way would be to temporarily redefine TMPDIR to some location that isn't mounted as noexec, such as /home/temp. You can do this with the export command like this:
~]# export TMPDIR="/home/temp"
You wouldn't want to leave TMPDIR defined this way though. You just want it temporarily pointing here so rbenv can run and then clean up after itself. Before export is run though, we would want to find out what TMPDIR is currently defined as so we can put it back the way we found it. To do this, you can use the following command:
~]# echo $TMPDIR
Suppose the TMPDIR is not normally defined in the server and gets set by an executable. When you run the export command you can check your work as follows:
[root@ruby-almalinux8 home]# echo $TMPDIR
/home/temp
After Ruby is installed, you can run this to set it back:
[root@ruby-almalinux8 ~]# export TMPDIR=""
[root@ruby-almalinux8 ~]# echo $TMPDIR
Install Ruby on Rails on AlmaLinux - Part 3: Setting Ruby Versions on AlmaLinux
Multiple Ruby versions can be installed on your AlmaLinux system. You can use RVM or rbenv to specify a preferred version to use.
Step 1: List Installed Ruby Versions
To list the installed Ruby versions, execute the below command in RVM:
~]# rvm list
Here is the output:
[root@ruby-almalinux8 ~]# rvm list
=> ruby-2.5.8 [ x86_64 ]
* ruby-2.5.9 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Step 2: Set the Default Version
You can set the default version from the list by executing the command below:
~]# rvm use 2.5.8 --default
Here is the output:
[root@ruby-almalinux8 ~]# rvm use 2.5.8 --default
Using /usr/local/rvm/gems/ruby-2.5.8
[root@ruby-almalinux8 ~]# rvm list
=* ruby-2.5.8 [ x86_64 ]
ruby-2.5.9 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Step 3: List the Available Ruby Versions
You can run the command below to list the available Ruby versions in rbenv.
~]# rbenv install -l
Here is the output:
[root@ruby-almalinux8 ~]# rbenv install -l
3.0.6
3.1.4
3.2.2
jruby-9.4.3.0
mruby-3.2.0
picoruby-3.0.0
truffleruby-22.3.1
truffleruby+graalvm-22.3.1
Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all / -L' to show all local versions.
Step 4: Specify a Preferred Default Version
A star (*) denotes the global version set. You can specify a preferred default version with the following command:
~]# rbenv global <version>
Here is the output:
[root@ruby-almalinux8 ~]# rbenv global 2.5.9
[root@ruby-almalinux8 ~]# rbenv versions
system
* 2.5.9 (set by /root/.rbenv/version)
Install Ruby on Rails on AlmaLinux - Part 4: Install Ruby Development Package & Rails as a Gem
Step 1: Install the Ruby Development Package
You can Install the Ruby Development package by executing the below command:
~]# sudo dnf install ruby-devel -y
Step 2: Install Rails as a Gem
Once Ruby is installed, you can quickly install Rails as a Gem by executing the command below:
~]# gem install rails
Step 3: Install a Preferred Version of Rails
You can also install a preferred version of Rails by executing the command below. Please replace with the Rails version as per your requirements:
gem install rails -v <version>
Step 4: Check the Rails Version
Once the installation is complete, execute the command below to check the Rails version:
~]# rails --version
Here is the output:
[root@ruby-almalinux8 ~]# rails --version
Rails 7.0.5
[root@ruby-almalinux8 ~]#
Install Ruby on Rails on AlmaLinux - Part 5: Test the Ruby on Rails Functionality
Rails comprise various scripts called generators that make application development easier. The new application generator is one of the generators that is used to construct a new Rails application. The new Rails application allows you to test out the functionality of Ruby on Rails.
Step 1: Create a New Rails Application
You can create a new Rails application named Sampleapps by executing the following command:
~]# rails new Sampleapps
This will create a Rails application called Sampleapps in the Sample Apps directory and use bundle install to install the gem dependencies already stated in the Gemfile.
Step 2: Switch to the Desired Directory
Once the Sampleapps application is created, you can now switch to the directory:
~]# cd Sampleapps
This directory contains various files and subdirectories. The main subdirectory is the app, which includes your application's assets, channels, controllers, helpers, jobs, mailers, models, and views.
Step 3: View Your Created Application
To view your newly created application, you can execute either of the below commands to start a web server:
~]# bin/rails server
or
~]# rails server
This will launch Puma, the web server that comes standard with Rails.
Step 4: View Your Application in Action
To view your application in action, you can access http://localhost:3000 from your web browser. The Rails default information page should be displayed:

Step 5: Exit the Web Server
You can use the CTRL+C keys exit the web server. The Rails test page is only accessible from your local system by default.
Step 6: View Rails Default Test Page From Another Computer
To view the Rails default test page from another machine on the network, you can execute the below command:
~]# rails server -b 0.0.0.0
Step 7: View Rails Default Test Page From Any Network System
You can now view the Rails test page from any network system by accessing http://ip-address:3000 in the browser window. In addition, you may need to allow Port 3000 on your firewall/router.
Step 8: Choose a Different Port
You can also choose a different port by adding the -p flag along with the port number, as seen below:
~]# rails server -b 0.0.0.0 -p 8080
You can now access your Rails application using the following URL: http://ip-address:8080.
Wrapping Up
You should now easily understand how to install Ruby on Rails on an AlmaLinux operating system and how to create and test a new Rails application using a web browser.
Our technical support is always available to assist with any issues related to this article, 24 hours a day, 7 days a week 365 days a year.
Related Articles:
- Stable Diffusion AI Image Generator (SDXL) — Using the Web UI
- How to Install VMware Tools on Ubuntu: Step-by-Step Guide
- How to Install WordPress on Linux (AlmaLinux)
- What is CentOS? Everything You Need to Know
- Virtual Desktop Environment — Configuring Kasm Workspaces
- Automating a Windows Cron Job via the Windows Task Scheduler
About the Author: Mohammed Noufal
Mohammed Noufal has worked as a senior server administrator for 8+ years. He can be found on LinkedIn to know more or connect.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
How to Install WordPress on Linux (AlmaLinux)
Read ArticleWhat is CentOS? Everything You Need to Know
Read ArticleWhat is CentOS? Everything You Need to Know
Read ArticleRedis as Cache: How It Works and Why You Should Use It
Read ArticleRefer-a-Friend Program for Website Hosting: Get $100 for Each Friend!
Read Article