Ruby Tutorial
Ruby CGI
Ruby Advanced
Ruby is quite simple to install on Linux systems. The following tutorial is for Ubuntu, but it can be adapted for other Linux distributions as well. Before you install Ruby, you might want to update your package lists:
sudo apt-get update
1. Installing Ruby from Repositories:
The easiest way to install Ruby is to use the package management system of your distribution. In Ubuntu, you can use apt-get
:
sudo apt-get install ruby-full
This command will install Ruby along with all development tools to your system.
2. Installing Ruby with Rbenv:
An alternative way to install Ruby is to use rbenv
, which is a Ruby version management tool. This way is a bit more complicated but gives you more control over which Ruby version you want to install, and it allows you to switch between different installed Ruby versions.
First, you need to install dependencies for rbenv
and ruby-build
:
sudo apt-get install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev
Then you can install rbenv
and ruby-build
:
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash
This script will install rbenv
into ~/.rbenv
with ruby-build as a plugin. Add ~/.rbenv/bin
to your $PATH
for access to the rbenv
command-line utility:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc source ~/.bashrc
Now you can install any version of Ruby you need:
rbenv install 2.7.1 rbenv global 2.7.1
This will install Ruby 2.7.1 and set it as the default version for your session.
3. Verifying the Installation:
Regardless of the installation method, you can check your Ruby version with:
ruby -v
This should output some information on the installed Ruby version. If it does, Ruby is correctly installed.
Remember to always check the official Ruby documentation and your distribution's guidelines if you encounter any problems.