In this tutorial we are going to learn how to install Ruby on Rails on Ubuntu 18.04. We will also install and configure its prerequisites. Ruby on Rails is one of the most popular application stacks for developers who looking to create web apps with Ruby language. Using Ruby language combined with the Rails framework has been simplified the app development.
I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 18.04 LTS Bionic Beaver minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.
Install Ruby on Rails on Ubuntu 18.04 Bionic Beaver
Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:
apt-get update -y apt-get upgrade -y
Step 2. Installing Ruby Version Manager.
First install the dependencies required for the RVM utility to build Ruby from source:
sudo apt install curl g++, gcc, autoconf, automake, bison, libc6-dev, libffi-dev, libgdbm-dev, libncurses5-dev, libsqlite3-dev, libtool, libyaml-dev, make, pkg-config, sqlite3, zlib1g-dev, libgmp-dev, libreadline-dev, libssl-dev
Next, run the following commands to install RVM:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB curl -sSL https://get.rvm.io | bash -s stable
Start using RVM:
Verify that Ruby was properly installed:
### ruby -v ruby 2.5.1p57 (2018-07-21 revision 63029) [x86_64-linux]
Step 3. Installing Rails.
Rails is a Ruby gem and different versions of Rails are available for installation too. To install Rails you can use the command below:
gem install rails
Now that you’ve installed Rails, you can run the rails -v command to make sure you have everything installed correctly:
### rails -v Rails 5.2.0
Step 5. Create a new Ruby on Rails application.
Now you are ready to start with your first Ruby on Rails project. Create a new Ruby on Rails application in your home directory:
cd ~ rails new firstMyproject