Ruby on Rails, commonly referred to as Rails, is an open-source web application development framework that has revolutionized the way web applications are built. Rails is known for its simplicity, efficiency, and productivity, making it an ideal choice for beginners and experienced developers alike. Debian 12, with its stability and security, provides a solid foundation for hosting Rails applications. This article guides you through the process of installing Ruby on Rails on Debian 12, ensuring a clear understanding for newcomers and providing in-depth information for all levels of expertise.
Step 1: Update Your System
Always start by updating your system to ensure all your packages are up to date. This minimizes potential conflicts and ensures a smooth installation process. Open a terminal and execute the following commands:
sudo apt update
sudo apt upgrade -y
Step 2: Install Ruby
Rails is a Ruby framework, so the first step is to install Ruby. We recommend using rbenv, a tool that lets you easily install and manage multiple Ruby versions.
- Install Dependencies Before installing rbenv, you need to install some dependencies:
sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev -y
- Install rbenv Clone the rbenv repository to your home directory:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Add rbenv to your path by adding the following lines to your ~/.bashrc
file:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
Apply the changes to your current session:
source ~/.bashrc
- Install ruby-build
ruby-build
is a plugin for rbenv that simplifies the installation of Ruby versions:
mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
- Install Ruby Install the latest stable version of Ruby:
rbenv install 3.0.0
rbenv global 3.0.0
Replace 3.0.0
with the latest stable version. Verify the installation:
ruby -v
Step 3: Install Rails
With Ruby installed, you can now proceed to install Rails.
- Install Bundler Bundler is a Ruby gem that manages your application’s dependencies. Install it using the gem command:
gem install bundler
- Install Rails Install Rails by running:
gem install rails
After installation, verify that Rails is installed:
rails -v
Step 4: Create a Test Application
To ensure that Rails is correctly installed, create a new Rails application:
rails new testapp
cd testapp
rails server
Open a web browser and navigate to http://localhost:3000
. You should see the Rails welcome page, indicating that your Rails installation is successful.
Integrating with Shape.host Services
After successfully installing Ruby on Rails on Debian 12, you might consider deploying your application. Shape.host offers Cloud VPS services that provide the perfect environment for hosting your Rails applications. With Shape.host, you benefit from fast SSD storage, robust security features, and scalable resources, ensuring that your application performs optimally. Whether you’re hosting a small project or a large-scale enterprise application, Shape.host’s Cloud VPS solutions are designed to meet your needs, providing the reliability and performance your online presence demands.