Installing Ruby on Rails on Ubuntu 20.04 Step by Step Tutorial

Installing Ruby on Rails on Ubuntu 20.04 Step by Step Tutorial

In this article, we will learn how to configure Ruby on Rails on Ubuntu 20.04 server Focal Fossa. We will install Ruby 2.7 with RVM, rbenv, and using the source. Now without wasting any more time let’s begin with this tutorial.

Before we start installing Ruby on Rails on the server, we need to install all the dependencies. We need to install Yarn and Nodejs repositories on the server. Execute the following set of commands on the server.

sudo apt install curl
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
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-get update
sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn

 

Installing Ruby on Rails using RVM on Ubuntu 20.04

Installing Ruby on Rails on the Ubuntu 20.04 with RVM is quite simple, just execute the following commands, step by step on the terminal.

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.7.1
rvm use 2.7.1 --default
ruby -v

PS: If you want to install any other version of Ruby, simply change the version number, while using RVM install command. For Example, for Ruby 2.6 version use this command.

rvm install 2.6
rvm use 2.6 --default

 

Installing Ruby using rbenv on ubuntu 20.04
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.7.1
rbenv global 2.7.1
ruby -v

 

Installing Ruby on Rails using the Source
cd
wget http://ftp.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.gz
tar -xzvf ruby-2.7.1.tar.gz
cd ruby-2.7.1/
./configure
make
sudo make install
ruby -v

 

The next step is to install Bundler

gem install bundler

If you are using the rbenv method, then execute the following command on the terminal.

rbenv rehash

Now let’s move on to the next part.

 

Installing Rails 6.0 on the Ubuntu server.
gem install rails -v 6.0.2.2

rbenv users need to use the following command after the Rails installation.

rbenv rehash

 

If you want to setup LAMP stack on the Ubuntu 20.04 then follow this tutorial.

https://www.myserverfix.com/how-to-setup-lamp-stack-apachemysql-php-on-ubuntu-20-04-server/

 

 

24 thoughts on “Installing Ruby on Rails on Ubuntu 20.04 Step by Step Tutorial”

  1. Very nice article and right to the point. I am not sure if
    this is truly the best place to ask but do you folks have any ideea where to employ some professional writers?
    Thanks in advance 🙂 Escape room lista

    Reply
  2. I’m impressed, I have to admit. Rarely do I come across a blog that’s equally educative and engaging, and let me tell you, you have hit the nail on the head. The problem is an issue that not enough men and women are speaking intelligently about. Now i’m very happy that I came across this during my hunt for something concerning this.

    Reply
  3. An interesting discussion is worth comment. I believe that you ought to write more on this subject, it may not be a taboo subject but typically folks don’t discuss such issues. To the next! All the best.

    Reply
  4. This is the perfect website for anyone who would like to find out about this topic. You realize so much its almost hard to argue with you (not that I personally would want to…HaHa). You certainly put a brand new spin on a subject that has been discussed for ages. Excellent stuff, just great.

    Reply
  5. Your style is really unique compared to other people I’ve read stuff from. Thanks for posting when you have the opportunity, Guess I will just book mark this site.

    Reply
  6. Hello there, I believe your website could possibly be having browser compatibility problems. When I look at your website in Safari, it looks fine but when opening in I.E., it has some overlapping issues. I simply wanted to give you a quick heads up! Aside from that, great website.

    Reply
  7. I really love your website.. Excellent colors & theme. Did you make this website yourself? Please reply back as I’m wanting to create my own personal site and would like to find out where you got this from or what the theme is named. Thanks!

    Reply
  8. I truly love your site.. Pleasant colors & theme. Did you build this site yourself? Please reply back as I’m hoping to create my own site and want to learn where you got this from or exactly what the theme is named. Cheers!

    Reply
  9. After looking over a handful of the articles on your blog, I honestly appreciate your way of writing a blog. I book-marked it to my bookmark website list and will be checking back soon. Please check out my website as well and let me know what you think.

    Reply
  10. Can I simply say what a relief to find somebody who really understands what they are talking about on the internet. You definitely realize how to bring an issue to light and make it important. More and more people ought to read this and understand this side of your story. I can’t believe you’re not more popular since you definitely have the gift.

    Reply

Leave a Comment