Hamsa K
Editor
9 min read | 3 years ago

How to Install Ruby on Rails on Debian 10

How to install Ruby on Rails on Debian 10

Ruby on Rails, or Rails, is a server-side web application framework written in Ruby under the MIT License. Rails is a model–view–controller framework, providing default structures for a database, a web service, and web pages.

In this Article, we will show you how to install Ruby on Rails on Debian Buster 10.

Step 1: Install RVM

First we will install ruby version manager to install ruby. Before installing rvm 

install the gnupg2 package using the apt command below.

sudo apt install gnupg2

Also Read -> How to Install Apache Tomcat 10 on Debian 10

Now, you need to download the GPG key to install RVM (Ruby Version Manager) and then install Ruby.

curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

Now run following command in order to install the latest stable version of RVM.

curl -sSL https://get.rvm.io | bash -s stable --ruby
root@debian:~# curl -sSL https://get.rvm.io | bash -s stable --ruby
Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc
gpg: Signature made Fri 15 Jan 2021 10:46:22 AM PST
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D  6956 105B D0E7 3949 9BDB
GPG verified '/usr/local/rvm/archives/rvm-1.29.12.tgz'
Creating group 'rvm'
Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete:
Searching for binary rubies, this might take some time.
No binary rubies available for: debian/10/x86_64/ruby-3.0.0.
-----------------------
Checking requirements for debian.
Installing requirements for debian.
Updating system..
Installing required packages: gawk, autoconf, automake, bison, libffi-dev, libgdbm-dev, libncurses5-dev, libsqlite3-dev, libtool, libyaml-dev, pkg-config, sqlite3, zlib1g-dev, libgmp-dev, libreadline-dev, libssl-dev...............
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-3.0.0, this may take a while depending on your cpu(s)...
ruby-3.0.0 - #downloading ruby-3.0.0, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 18.6M  100 18.6M    0     0   561k      0  0:00:33  0:00:33 --:--:--  625k
ruby-3.0.0 - #extracting ruby-3.0.0 to /usr/local/rvm/src/ruby-3.0.0.....
ruby-3.0.0 - #configuring.........................................................................
ruby-3.0.0 - #post-configuration..
ruby-3.0.0 - #compiling..........................................................................................
ruby-3.0.0 - #installing.....................
ruby-3.0.0 - #making binaries executable...
Installed rubygems 3.2.3 is newer than 3.0.9 provided with installed ruby, skipping installation, use --force to force installation.
ruby-3.0.0 - #gemset created /usr/local/rvm/gems/ruby-3.0.0@global
ruby-3.0.0 - #importing gemset /usr/local/rvm/gemsets/global.gems................................................................
ruby-3.0.0 - #generating global wrappers........
ruby-3.0.0 - #gemset created /usr/local/rvm/gems/ruby-3.0.0
ruby-3.0.0 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-3.0.0 - #generating default wrappers........
ruby-3.0.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-3.0.0 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
Creating alias default for ruby-3.0.0....
* To start using RVM you need to run `source /usr/local/rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

The process will take some time depending on your Internet speed, after which RVM will be installed on your system.Once the installation is complete, load the RVM to the Debian system.

source /usr/local/rvm/scripts/rvm

you can check the version number of RVM installed on your system.

rvm --version

sample output:

root@debian:~# rvm --version
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

Also you can check ruby version with the follwing command.

ruby -v

sample output:

root@debian:~# ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

Also Read -> How to Install Docker on Debian 10

Step 2: Install rails

RubyGems is a Ruby Package Manager, coming with the gem command-line tool and automatically installed when we install Ruby on the system.

you can install the latest version of Ruby on Rails through the gem command-line tool as follows.

gem install rails

you can check rails version as below

rails -v

sample output:

root@debian:~# rails -v
Rails 6.1.3.1

Step 3: Install nodejs and gcc compiler

Before starting with the Rails development on Debian, we recommend using Nodejs as the Javascript runtime. It is prerequisite for compiling Ruby on Rails.you can use following command in order to install Nodesource repository to your system and also install gcc compiler.

sudo apt install gcc g++ make
curl -sL https://deb.nodesource.com/setup_12.x | bash -

now install nodejs

sudo apt install nodejs

Also install yarn with the following commands.

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

check nodejs and yarn versions.

node --version
yarn --version

Also Read -> How to Install Apache Maven on Debian 10

Step 4: start New project

Now we’re going to create a new project for Ruby on Rails. For this we will create one new folder.

mkdir /home/lampblogs/myfirstproject
cd /home/lampblogs/myfirstproject

now create project as below.

rails new project

now go to project folder and run below command.

cd project
rails s

sample output:

=> Booting Puma
=> Rails 6.1.3.1 application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.2.2 (ruby 3.0.0-p0) ("Fettisdagsbulle")
*  Min threads: 5
*  Max threads: 5
*  Environment: development
*          PID: 1630
* Listening on http://127.0.0.1:3000
* Listening on http://[::1]:3000
Use Ctrl-C to stop

you can also use ip address and port like below.

rails server --binding 192.168.1.159 --3000

open your browser and type 192.168.1.159:3000

sample output:

 

That's it.Now you have successfully installed ruby on rails on debian 10 system.

Also Read -> How to Install php 8 on Debian 10



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy