Introduction
In this article, we will provide basic steps on how to install Ruby on Rails on a Ubuntu-based VPS server.
Ruby is known among programmers for a terse, uncluttered syntax that doesn’t require a lot of extra punctuation. Compared to Java, Ruby is streamlined, with less code needed to create basic structures such as data fields.
Rails is a framework for building websites. As such, Rails establishes conventions for easier collaboration and maintenance.
1. Update your system
sudo apt update
sudo apt upgrade
2. Installing the required dependencies
To compile Ruby and some Rails gems, we have to install dependencies using the following command line:
sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool pkg-config sqlite3 nodejs npm
3. Installing rbenv
rbenv is a version manager tool for the Ruby programming language:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
4. Installing Ruby-build:
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
5. Installing Ruby
rbenv install 3.4.5
Installation can take about 15 minutes; be patient.
Once the installation is complete, be sure to set the newly installed version of Ruby as the default version of rbenv:
rbenv global 3.4.5
6. Installing Rails
gem install rails
7. Verify the installation
ruby -v
rails -v