In this tutorial we will show you how to install Ruby on Rails on your Debian 9. For those of you who didn’t know, For those of you who didn’t know, Ruby on Rails (RoR) is a framework written in the Ruby programming language that allows you to use Ruby in combination with HTML, CSS, and similar programming languages. It is used by many developers since it makes the application development very simple.
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 through the step by step installation Ruby on Rails on a Debian 9 (Stretch) server.
Install Ruby on Rails on Debian 9 Stretch
Step 1. Before we install any software, it’s important to make sure your system is up to date by running these following apt-get commands in the terminal:
Step 2. Installing RVM.
One way of installing Ruby on Rails on an vps is by using the Ruby enVironment Manager, or shortly RVM. We will use RVM to install Ruby on Rails in this tutorial. In order to install RVM on your server, you can use the following commands:
apt-get install curl gnupg2 dirmngr
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
Use curl command to install RVM:
curl -sSL https://get.rvm.io | bash -s stable
Load RVM environment variables using below command:
Run the following command to get a list of ruby versions available for your system:
rvm list known
The list result should look like the following one:
# MRI Rubies
[ruby-] 1.8.6 [-p420]
[ruby-] 1.8.7 [-head] # security released on head
[ruby-] 1.9.1 [-p431]
[ruby-] 1.9.2 [-p330]
[ruby-] 1.9.3 [-p551]
[ruby-] 2.0.0 [-p648]
[ruby-] 2.1 [.8]
[ruby-] 2.2 [.4]
[ruby-] 2.3 [.0]
[ruby-] 2.4 [.1]
Use the following command to install Ruby 2.4.1:
rvm install 2.4.1
If you want to make that version the default, add that at the end:
rvm use 2.4.1 --default
Now that RVM is installed and configured and Ruby is on the system, you can install Rails. Rails is available as a Gem, which is a Ruby package. When Ruby is installed, its native Gem packaging system is also installed. Installing Ruby packages is very similar to any Linux package manager. To install Rails you can use the command below:
gem install rails
Check rails version:
# rails -v
Now you are ready to start with your first Ruby on Rails project. Create a new Ruby on Rails application in your home directory:
rails new idrootApps
This should take no longer than a minute. Once your new Ruby on Rails application is created, you can start developing the application. There are new guides for Rails 5.0 which will help you understand how all of the pieces fit together.
Congratulation’s! You have successfully installed Ruby on Rails. Thanks for using this tutorial for installing the latest version of Ruby on Rails on Debian 9 Stretch server. For additional help or useful information, we recommend you to check the official Ruby on Rails web site.