[2 min installs] Ruby on Rails on Ubuntu
Better Stack Team
Updated on August 30, 2022
Here is how to install Ruby on Rail in under two minutes:
Step 1 - Install dependencies
Before installing Ruby on Rails, you need to install its dependencies first.
- Update package list on your system:
sudo apt-get update -y
- Install
build-essentials
sudo apt-get install build-essential
- Install the developer dependencies.
sudo apt-get install libssl-dev zlib1g-dev sqlite3 libsqlite3-dev
- Install Git and curl if not already installed.
sudo apt-get install git curl
Step 2 - Install Nodejs & Yarn
Rails use the JavaScript runtime through Node.js to build the applications.
- Install the latest Node.js version (if not already installed)
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install nodejs
- Install Yarn
curl -fsSL 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 yarn
Step 3 - Install rbenv
rbenv
is a Ruby version manager used to install and manage Ruby environments.
- Install
rbenv
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
- Add
rbenv
to the path
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init - bash)"' >> ~/.bashrc
exec $SHELL
Step 4 - Install Ruby
Now it is time to install the latest stable version of Ruby language. If you have done this already, you can skip this step.
- List the latest Ruby versions
rbenv install -l
- Install the desired version (rails require version 2.5.0 or newer)
rbenv install 3.0.2 -v
- Set global Ruby version
rbenv global 3.0.2
- Install ruby bundler using
gem
gem install bundler
Step 5 - Install Rails
Finally, install rails using the following command:
gem install rails
That’s it
You have installed Ruby on Rails on your system. To test if everything worked, create a test project and run it:
rails new hello-world
cd hello-world
rails server --binding=0.0.0.0
http://192.0.2.123:3000
Got an article suggestion?
Let us know
Next article
[2 min installs] Nginx on Ubuntu
→
Check Uptime, Ping, Ports, SSL and more.
Get Slack, SMS and phone incident alerts.
Easy on-call duty scheduling.
Create free status page on your domain.