Ruby on Rails is a powerful web application framework built on the Ruby programming language. It is designed to make web development faster and easier by following the principles of convention over configuration. In this guide, we will walk through the steps to install Ruby on Rails on Ubuntu 22.04.

Step 1: Update Your System

Before starting the installation process, update your system’s package index:

sudo apt update && sudo apt upgrade

Step 2: Install Dependencies

Install essential packages required for Ruby on Rails and system development:

sudo apt install curl g++ gcc make libssl-dev libreadline-dev zlib1g-dev git

Step 3: Install rbenv and ruby-build

rbenv is a version manager for Ruby that allows you to easily switch between Ruby versions. Install rbenv and ruby-build (used to compile and install Ruby versions) by running the following commands:

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
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Step 4: Install Ruby

Now you can install Ruby using rbenv. To install the latest stable version of Ruby, run the following command:

rbenv install 3.1.0

After the installation, set this version of Ruby as the default:

rbenv global 3.1.0

Verify the installation by checking the Ruby version:

ruby -v

Step 5: Install Node.js and Yarn

Ruby on Rails requires a JavaScript runtime for asset compilation. Install Node.js and Yarn package manager:

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install -y nodejs
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn

Step 6: Install Rails

With Ruby installed, you can now install Rails using the gem package manager:

gem install rails

After the installation is complete, verify the Rails version:

rails -v

Step 7: Create a New Rails Application

Once Rails is installed, you can create a new Rails application. Navigate to the directory where you want to create your application and run the following command:

rails new myapp

Navigate into the project directory:

cd myapp

Start the Rails server:

rails server

Now, open your web browser and visit http://localhost:3000 to see your new Rails application in action.

Conclusion

Congratulations! You have successfully installed Ruby on Rails on Ubuntu 22.04. With Rails, you can now build powerful web applications using the conventions and features provided by this popular framework.

If you're looking for a reliable hosting solution for your Rails application, consider using Windows VPS UK. With Windows VPS, you get high-performance hosting that's perfect for web development projects. Whether you need VPS UK Windows or Windows Virtual Private Servers, you'll find a solution tailored to your needs.

For more advanced hosting needs, explore Windows Virtual Dedicated Server Hosting or Virtual Private Server Hosting Windows. Whether you're based in the UK, Italy, or anywhere else, Windows VPS Italy and UK VPS Windows offer secure and scalable hosting solutions. Visit Windows VPS Hosting UK to discover the best hosting options for your Ruby on Rails project.

Was this answer helpful? 0 Users Found This Useful (0 Votes)