In this tutorial, we will show you how to install Ruby on Rails on Debian 11. For those of you who didn’t know, Ruby on Rails is a free, open-source, and one of the most popular application stacks used for creating sites and web apps. It is written in Ruby programming language and follows the MVC (Model-View-Controller) concept.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the GIMP open-source image editor on a Debian 11 (Bullseye).
Prerequisites
- A server running one of the following operating systems: Debian 11 (Bullseye).
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Ruby on Rails on Debian 11 Bullseye
Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt
commands in the terminal:
sudo apt update sudo apt upgrade sudo apt install gnupg2 curl wget gcc g++ make
Step 2. Installing RVM.
By default, RVM is not available from the default Ubuntu base repository. Now run the following command below to add the RVM repository and import the GPG key:
gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
After that, download and run the RVM installation script:
curl -sSL https://get.rvm.io | bash -s stable --ruby
Next, load the RVM system path using the following command:
source /usr/local/rvm/scripts/rvm
Verify the RVM installation version:
rvm version
Step 3. Installing Ruby using RVM.
Ruby package is available in the default Debian repositories. First, we update RVM to the latest version by issuing a command:
rvm get stable --autolibs=enable
Next, add the root user to the RVM group so that the root user can run the RVM command.:
usermod -a -G rvm root
Then, install the latest version of Ruby using the following command below:
rvm install ruby-3.0.2 rvm --default use ruby-3.0.2
You can confirm installation by issuing the below command:
ruby --version
Step 4. Installing Nodejs and Yarn.
By default, Nodejs is not available on the Debian 11 base repository. Now we add the Node source repository using the following command:
curl -sL https://deb.nodesource.com/setup_14.x | bash -
Next, run the following command to add the Yarn repository:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
After that, update the apt repository and install Nodejs and Yarn packages using the following command below:
sudo apt update sudo apt install nodejs yarn
Verify the Nodejs version:
node --version
Verify the Yarn version:
yarn --version
Step 5. Installing Ruby on Rails on Debian 11.
First, run the following command to update the RubyGem to the latest version:
gem update --system
Next, we install the latest version of Ruby on Rails using the RubyGem command below:
gem install rails -v 6.1.4
Verify the installed version of Rails using the following command:
rails -v
Step 6. Create a Test Application.
Now we create a new project using Rails:
rails new project cd project
After that, start the puma rails web server using the command below:
rails s -b 192.168.77.21 -p 8080
Output:
=> Booting Puma => Rails 6.1.4.1 application starting in development => Run `bin/rails server --help` for more startup options Puma starting in single mode... * Puma version: 5.5.2 (ruby 3.0.2-p107) ("Zawgyi") * Min threads: 5 * Max threads: 5 * Environment: development * PID: 46462 * Listening on http://192.168.77.21:8080 Use Ctrl-C to stop
Once successfully create a new project, now access it using the URL http://your-server-ip-address:8080
. You should see the Rails default page:
Congratulations! You have successfully installed Ruby on Rails. Thanks for using this tutorial for installing the latest version of Ruby on Rails on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official Ruby on Rails website.