Skip to content

Instantly share code, notes, and snippets.

@soardex
Created May 9, 2015 01:15
Show Gist options
  • Save soardex/e95cdc230d1ac5b824b3 to your computer and use it in GitHub Desktop.
Save soardex/e95cdc230d1ac5b824b3 to your computer and use it in GitHub Desktop.
Install rbenv in CentOS 7
# install build dependencies
sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
# clone and install rbenv environment
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
# re-init bash
source ~/.bash_profile
# install latest ruby
rbenv install -v 2.2.2
# sets the default ruby version that the shell will use
rbenv global 2.2.2
# to disable generating of documents as that would take so much time
echo "gem: --no-document" > ~/.gemrc
# install bundler
gem install bundler
# must be executed everytime a gem has been installed in order for the ruby executable to run
rbenv rehash
Copy link

ghost commented Aug 18, 2017

Thanks a lot my dude, very useful Gist

@Francoois
Copy link

Yes thank you a lot ! <3

@daverogers
Copy link

rbenv rehash is depreciated as it's now part of the core.

@shal
Copy link

shal commented Sep 22, 2018

Thanks @soardex, it was very useful!

@kirkog86
Copy link

This is great! Thanks

@greenbicycle
Copy link

Very useful. I am using it as part of a docker environment that will deploy PHP code via capistrano.

@flyeagles
Copy link

Works on CentOS 6 too. Thanks a lot.

@otheus
Copy link

otheus commented Feb 9, 2021

Why can't you make an RPM for rbenv and put it on EPEL?

@k8s-ap
Copy link

k8s-ap commented May 19, 2021

Thanks you very much

@marijus-ravickas
Copy link

For some packages(example: libyaml-devel). You might need to enable epel and powertools repos for rhel8 based OS'es. Tested on rocky.

sudo dnf install epel-release
sudo dnf config-manager --set-enabled powertools

@Faq
Copy link

Faq commented Nov 17, 2022

ruby-build has now:
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

@EshginGuluzade
Copy link

EshginGuluzade commented Dec 9, 2022

FYI, for CentOS 9, powertools are called crb(CodeReady Linux Builder), so you need to run below command to enable powertools to install libyaml-devel

dnf config-manager --set-enabled crb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment