Install Dependencies
yum install git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl postgresql-devel
Install rbenv
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exec $SHELL
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
exec $SHELL
.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
source ~/.bash_profile
List Ruby version
rbenv install -l
2.4.4
2.5.0-dev
2.5.0-preview1
2.5.0-rc1
2.5.0
2.5.1
2.6.0-dev
2.6.0-preview1
2.6.0-preview2
Install Ruby 2.5.1
rbenv install -v 2.5.1
rbenv global 2.5.1
Check Ruby version
# ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Install Bundler
gem install bundler
Install Rails 5.2.0
gem install rails -v 5.2.0
Check Ruby on Rails version
# rails -v
Rails 5.2.0
Reference
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-centos-7