Skip to main content
  1. Posts/

Install Ruby di CentOS 7

2 mins
ruby ruby centos
Table of Contents

Ruby adalah bahasa pemrograman simple yang cukup diminati, khususnya pada perusahaan besar baik untuk pengembangan web frontend, backend hingga testing dapat dilakukan menggunakan ruby.

Install Ruby
#

yum -y install ruby

Namun versi ruby bawaan CentOS 7 adalah versi 2.0.0 (Deprecated)

Versi ruby terbaru bisa kalian install dengan beralih ke OS terbaru seperti CentOS 8 Stream atau bisa juga install ruby dengan Rbenv

Install Ruby dengan Rbenv
#

Install terlebih dahulu paket dependensinya

yum install git libreadline-dev zlib1g-dev libreadline-dev libncurses5-dev autoconf bison libssl-dev build-essential libyaml-dev libffi-dev libssl-dev libreadline-dev zlib1g-dev libgdbm-dev

Buat user [Optional]

useradd -m jeky

Step bisa kalian lewati apabila lebih ingin menjalankan sebagai root {: .prompt-tip }

Login ke user yang sudah dibuat dan clone repo rbenv

git clone https://github.com/rbenv/rbenv.git ~/.rbenv

Setting PATH untuk rbenv/bin

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc

Selanjutnya install ruby-build plugin

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

Setting PATH untuk ruby-build

echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc

Install ruby dengan perintah berikut

rbenv install 2.6.1

versi ruby yang tersedia dapat dicek pada page Ruby Releases {: .prompt-tip }

Output

To follow progress, use 'tail -f /tmp/ruby-build.20230102215027.2269.log' or pass --verbose
No system openssl version was found, ensure openssl headers are installed (https://github.com/rbenv/ruby-build/wiki#suggested-build-environment)
Downloading openssl-1.1.1s.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa
Installing openssl-1.1.1s...
Installed openssl-1.1.1s to /home/jeky/.rbenv/versions/2.6.1

Downloading ruby-2.6.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.1.tar.bz2
Installing ruby-2.6.1...

WARNING: ruby-2.6.1 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

Installed ruby-2.6.1 to /home/jeky/.rbenv/versions/2.6.1


NOTE: to activate this Ruby version as the new default, run: rbenv global 2.6.1

Untuk mengaktifkan versi Ruby sebagai default

rbenv global 2.6.1

Cek versi ruby

[jeky@localhost ~]$ ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]

Related

RPM-GPG-KEY-AlmaLinux Update Failure
1 min
centos centos almalinux
Configuring Networks on CentOS
1 min
centos centos
Create Bridges on Bonds with and without VLANs using NetworkManager
1 min
centos linux centos
Compiling Custom Kernel Modules
3 mins
linux linux centos
Reinstalling GRUB Bootloader
1 min
linux linux centos
Setting Default Kernel in Linux
2 mins
linux linux centos ubuntu