Ruby on Rails, often simply Rails, is a server-side web application framework written in Ruby. It is a model-view-controller (MVC) framework, providing default structures for a database, a web service, and web pages. Its use of the convention over configuration (CoC) paradigm, the dry principle, and the active record pattern has made it a favorite among web developers for its ease of use and speed of development. This guide will walk you through installing Ruby on Rails on AlmaLinux 9, aiming to make the process clear and straightforward for newcomers while providing depth for more seasoned developers.
Step 1: System Update
Begin by updating your system. This ensures that all your system packages are up to date, reducing the risk of compatibility issues. Open your terminal and run:
sudo dnf update -y
Step 2: Installing Ruby
Rails is a Ruby gem, so you must install Ruby first. While AlmaLinux repositories include Ruby, they might not always have the latest version. For this guide, we’ll use RVM (Ruby Version Manager) to install Ruby, which allows you to manage multiple Ruby environments.
- Install RVM First, install the GPG keys:
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Then, install RVM:
curl -sSL https://get.rvm.io | bash -s stable
After installation, load RVM into your shell session:
source /etc/profile.d/rvm.sh
- Install Ruby Use RVM to install the latest stable version of Ruby:
rvm install ruby
Set the default Ruby version with:
rvm use ruby --default
- Verify Ruby Installation Confirm that Ruby is correctly installed:
ruby -v
This command displays the installed Ruby version.
Step 3: Installing Rails
With Ruby installed, you can now install Rails. Rails can be installed as a Ruby gem.
gem install rails
This installs the latest version of Rails. Verify the Rails installation by checking its version:
rails -v
Step 4: Setting Up a Rails Application
Now that you have Rails installed, let’s create a new Rails application to test your installation:
- Create a New Rails App
rails new myapp
Replace myapp
with your desired application name. This command creates a new Rails application directory with all the necessary files.
- Start the Rails Server Navigate to your application directory:
cd myapp
Start the Rails server:
rails server
Visit http://localhost:3000
in your web browser. You should see the Rails welcome page, indicating your Rails application is running successfully.
Integrating with Shape.host Services
After successfully setting up Ruby on Rails on AlmaLinux 9, you may be considering deployment options for your application. Shape.host offers Linux SSD VPS services that provide a perfect hosting environment for Ruby on Rails applications. With Shape.host, you benefit from fast SSD storage, robust security features, and scalable resources to match your application’s growth needs. Whether you’re developing a small project or a large-scale enterprise application, Shape.host’s Linux SSD VPS solutions ensure your web application remains performant and accessible.