
- Ruby on Rails - Home
- Ruby on Rails - Introduction
- Ruby on Rails - Installation
- Ruby on Rails - IDEs
- Ruby on Rails - Hello World
- Ruby on Rails - Framework
- Ruby on Rails - Directory Structure
- Ruby on Rails - Rails Console
- Ruby on Rails - Bundler
- Ruby on Rails - Examples
- Ruby on Rails - Database Setup
- Ruby on Rails - Active Records
- Ruby on Rails - Validation
- Active Record Associations
- Active Record Query
- Ruby on Rails - Migrations
- Ruby on Rails - Active Model
- Ruby on Rails - Controllers
- Cookies and Session
- Ruby on Rails - Authentication
- Ruby on Rails - Routes
- Ruby on Rails - Views
- Ruby on Rails - Rendering
- Ruby on Rails - Layouts
- Ruby on Rails - Scaffolding
- Ruby on Rails - Forms
- Ruby on Rails - Active Jobs
- Ruby on Rails - Action Text
- Ruby on Rails - Active Storage
- Ruby on Rails - JavaScript
- Ruby on Rails - Propshaft
- Ruby on Rails - ImportMap
- Ruby on Rails - AJAX
- Ruby on Rails - WebSockets
- Ruby on Rails - Action Cable
- Ruby on Rails - File Uploading
- Ruby on Rails - Send Emails
- Ruby on Rails - Rack
- Ruby on Rails - Error Handling
- Ruby on Rails - Deployment
- Ruby on Rails Resources
- Ruby on Rails - References Guide
- Ruby on Rails - Quick Guide
- Ruby on Rails - Resources
- Ruby on Rails - Discussion
- Ruby Tutorial
- Ruby Tutorial
Ruby on Rails - Installation
To develop a web application using Ruby on Rails Framework, you need to install the following software −
- Ruby
- The Rails Framework
- A Web Server
- A Database System
Ruby is a programming language, whereas Rails is a web development framework built on Ruby. Rails includes a built-in web server called Puma for local development purposes. For Production: You'll need a proper web server setup like Puma with Nginx, lightTPD or Apache.
Rails works with many database systems, including MySQL, PostgreSQL, SQLite, Oracle, DB2 and SQL Server. Please refer to a corresponding Database System Setup manual to set up your database.
Let's look at the installation instructions for:
- Linux (Ubuntu)
- Windows
- macOS
Installing Rails on Linux (Ubuntu)
We are installing Ruby on Rails on Ubuntu Linux using RVM (Ruby Version Manager). You can also use rbenv, it is also a lightweight Ruby Version Management Tool.
- RVM Installs Ruby in its own environment. It provides built-in gemset support.
- On the other hand, rbenv provides an easy installation, it works by shimming Ruby versions into PATH, but requires additional plugins for gemsets.
Follow the steps given below to install Ruby on Rails using RVM tool.
Update System Packages
Start by updating the system package list and upgrading existing packages −
$ sudo apt update && sudo apt upgrade -y
Install Dependencies
Install the required dependencies for Ruby and Rails −
$ sudo apt install -y curl gnupg2 dirmngr git-core zlib1g-dev build-essential \ libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 \ libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common \ libffi-dev
It installs the general development tools, libraries for Rails, XML and HTML Processing, networking and software management.
You also need to install Node.js. Rails uses Node.js to handle JavaScript assets. Installation of Yarn is optional, used for managing JavaScript dependencies in Rails projects.
Install the latest version of Node.JS −
$ curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash $ sudo apt install -y nodejs
Install Ruby Version Manager RVM
$ gpg2 --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Load RVM into your Shell
$ source ~/.rvm/scripts/rvm
Install Ruby
$ rvm install 3.4.1 $ rvm use 3.4.1 --default
Check the Ruby version
$ ruby -v ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
Installation using rbenv
If you prefer using rbenv, then install rbenv and ruby-build &minus
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc $ echo 'eval "$(rbenv init -)"' >> ~/.bashrc $ source ~/.bashrc $ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Now, install Ruby −
$ rbenv install 3.2.2 $ rbenv global 3.2.2
Verify the Ruby version −
$ ruby -v ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
Install Bundler
Bundler is used to manage gems in Rails projects −
$ gem install bundler Fetching bundler-2.6.3.gem Successfully installed bundler-2.6.3 1 gem installed
You can now install Rails
$ gem install rails
Verify the installation
$ rails -v Rails 8.0.1
Installing Rails on Windows
The recommended way to install Ruby on Rails on Windows is to use the Windows Subsystem for Linux (WSL). Alternately, you can install Ruby by Using RubyInstaller for Windows and then install Rails on it.
Installation Using WSL
Windows Subsystem for Linux (WSL) is a new feature of Microsoft Windows with which you can use a Linux environment without the need for a separate virtual machine or dual booting. WSL is installed by default in Windows 11. It can also be enabled on Windows 10 by turning on the Virtual Machine Platform.
Open PowerShell or Windows Command Prompt and run −
$ wsl --install --distribution Ubuntu-24.04
You may need to reboot during the installation process. You can now open Ubuntu from the Start menu. Enter a username and password for your Ubuntu user when prompted.
To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64) lathkar@GNVBGL3:~$
You can now install Ruby and Ruby on Rails, by following the steps explained in the previous section (Installation on Ubuntu Linux)
Installation Using RubyInstaller
This Method offers a simpler alternative, its a native Windows installation without requiring WSL. Hence you dont need to switch between Windows and WSL. This is especially suitable for smaller projects or learning Rails. RubyInstaller for Windows installs Ruby for system-wide use by default and not a virtual environment (RVM or rbenv)
Go to the RubyInstaller website and download the recommended version from https://rubyinstaller.org/downloads/. Ruby+Devkit 3.3.7.1 version is a stable version, hence download and install the same.

During installation, ensure the MSYS2 development toolchain option is selected. MSYS2 is a software distribution and development environment for Windows that provides a minimal Linux-like shell and a package management system.
After the wizard steps are completed, the command terminal open up and asks you to install MSYS2 and MINGW toolchains.

You should run the ridk enable command before installing Rails when using RubyInstaller on Windows. This step ensures that the MSYS2 development toolchain and its environment are properly set up, allowing Ruby and Rails to work seamlessly.
C:\Users\mlath>ridk enable
Now you can install Rails using the gem install rails command −

Check the Rails version −
C:\Users\mlath>rails -v Rails 8.0.1
Installing Rails on MacOS
The macOS environment is very much like Unix. You need to install Xcode Command Line Tools, which include essential tools like git and make.
xcode-select install
Install Homebrew
Homebrew is a package manager for macOS that simplifies installing software.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
The subsequent steps of installation of RVM/rbenv, Ruby and Rails are similar to those explained in the installation of Ubuntu Linux section.
Installation Verification
After performing the installation by following the steps explained above, you can test the installation by creating a new Rails app with the following command −
$ rails new myapp

Navigate into the app directory −
cd myapp
Start the Rails server with the following command −
bin/rails server
Visit http://localhost:3000 in your browser to see the Rails welcome page.

To stop the server, press "Ctrl + C".
^C- Gracefully stopping, waiting for requests to finish === puma shutdown: 2025-01-27 00:48:24 +0530 === - Goodbye! Exiting
You have thus successfully installed Ruby on Rails on your system.