How to Install Ruby on CentOS 8
Ruby is one of the most famous dialects today. It has an exquisite punctuation, and it is the language behind the Ruby on Rails structure.
In this article, we will investigate various approaches to introduce Ruby on CentOS 8.
We'll tell the best way to introduce Ruby from the default CentOS 8 vaults and utilizing the Rbenv and RVM contents. Pick the establishment technique that is generally suitable for your arrangement and climate.
Installing Ruby from the CentOS repositories
This is the least demanding technique for introducing Ruby on CentOS. At the hour of composing, the form in the standard CentOS archives is 2.5.5.
Run the accompanying order as root or client with sudo benefits to introduce the ruby bundle:
sudo dnf install ruby
When the establishment is finished, you can confirm that it was effective by printing the Ruby form:
ruby --version
The yield will look something like this:
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
Your Ruby form may contrast from the one appeared previously.
That is it! You have effectively introduced Ruby on your CentOS framework, and you can begin utilizing it.
Install Ruby with Rbenv
Rbenv is a lightweight Ruby form the executives utility that permits you to handily switch Ruby variants.
We'll utilize the ruby-form module that expands the center usefulness of Rbenv and permit you to introduce any Ruby adaptation from source.
Start by introducing git and different conditions needed to construct Ruby from the source:
sudo dnf install git wget gcc bzip2 openssl-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel
Run the accompanying order to introduce both rbenv and ruby-form:
wget -q https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer -O- | bash
The content will clone both rbenv and ruby-form storehouses from GitHub to ~/.rbenv index.
Before beginning utilizing rbenv, you have to include $HOME/.rbenv/receptacle to your PATH .
In the event that you are utilizing Bash, type:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
In the event that you are utilizing Zsh type:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc
Run the rbenv - v order to guarantee that establishment was fruitful:
rbenv -v
rbenv 1.1.2-17-g7795476
To get a rundown of all Ruby forms that can be introduced with rbenv enter:
rbenv install -l
For example, if you want to install the Ruby 2.7.0 and set it as default version you would type:
rbenv install 2.7.0rbenv global 2.7.0
Verify that Ruby was properly installed by printing the version number:
ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
Installing Ruby with RVM
RVM (Ruby Version Manager) is an order line instrument that permits you to introduce, oversee, and work with various Ruby conditions.
To begin with, introduce the conditions required for rvm to construct Ruby from source:
sudo dnf install curl gcc bzip2 openssl-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel
Run the accompanying orders to import the GPG keys and introduce RVM:
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
To begin utilizing RVM you have to run the accompanying source order:
source ~/.rvm/scripts/rvm
To get a rundown of all known Ruby variants type:
rvm list known
In the event that for instance, you need to introduce Ruby 2.6 and set it as the default rendition you would give the accompanying orders:
rvm install 2.6
rvm use 2.6 --default
Check the establishment:
ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
For more data about how to deal with your Ruby establishments with RVM visit the RVM Documentation page .
Conclusion
We have given you three distinct approaches to introduce Ruby on your CentOS 8 worker. The strategy you pick relies upon your prerequisites and inclinations. Despite the fact that introducing the bundled adaptation from the CentOS vault is simpler, the Rbenv and RVM techniques give you greater adaptability for including and eliminating diverse Ruby variants on a for every client premise.
In the event that you have any inquiries or criticism, don't hesitate to remark beneath.