Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
In this tutorial we will show you three different ways to install Ruby on CentOS. Each
has their own benefits, you can choose one of the installation method that will work
best for you.
Ruby is one of the most popular languages today. It has an elegant syntax and it is the
language behind the Ruby on Rails framework.
Prerequisites
Before starting with the tutorial, make sure you are logged in as a user with sudo
privileges.
Install Ruby
The easiest way to install Ruby on your CentOS system is through the yum package
manager. At the time of writing, the version in the CentOS repositories is 2.0.0 which
is pretty outdated.
2. Once the installation is completed, you can verify that it was successful by
printing the Ruby version:
We will also install the ruby-build plugin that extends the core functionality of Rbenv
allowing us to easily install any Ruby version from source.
2. Next, run the following curl command to install both rbenv and ruby-build:
1 of 3 11/15/18, 10:53 PM
How To Install Ruby on CentOS 7 https://linuxize.com/post/how-to-install-ruby-on-c...
The script will clone both rbenv and ruby-build repositories from GitHub to
~/.rbenv directory. The installer script also calls another script which will try to
verify the installation. The output of the script will look something like below:
As you can see in the output above, before starting using rbenv we need to add
$HOME/.rbenv/bin to our PATH.
3. Now what we have rbenv installed on our system we can easily install the latest
stable version of Ruby and set it as as our default version with:
rbenv install 2.5.1
rbenv global 2.5.1
To list all available Ruby versions you can use: `rbenv install -l`
Verify that Ruby was properly installed by printing the version number:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
2 of 3 11/15/18, 10:53 PM
How To Install Ruby on CentOS 7 https://linuxize.com/post/how-to-install-ruby-on-c...
1. First we need to install the dependencies required for the RVM utility to be able
to build Ruby from source:
sudo yum install curl gpg gcc gcc-c++ make patch, autoconf, automake, bison, libffi-devel,
3. Install the latest stable version of Ruby with RVM and set it as as the default
version with:
rvm install 2.5.1
rvm use 2.5.1 --default
Verify that Ruby was properly installed by printing the version number:
ruby -v
For more information about how to manage your Ruby installations with RVM visit
the RVM Documentation page.
Conclusion
We have shown you three different ways to install Ruby on your CentOS 7 server. The
method you choose depends on your requirements and preferences. Even though
installing the packaged version from the CentOS repository is easier, the Rbenv and
RVM methods gives you more flexibility for adding and removing different Ruby
versions on a per user basis.
3 of 3 11/15/18, 10:53 PM