rbenvとruby-buildでRubyのインストール環境を揃える
- gitをインストール
yum install -y git
- gitをインストールしたら次にrbenvをインストール
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
ruby-buildをインストール
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
cd ~/.rbenv/plugins/ruby-build
./install.sh
Ruby 2.3.1をインストール
rbenv install -l
実行結果
2.3.1
2.4.0-dev
.
.
.
はじめにrubyの依存パッケージをインストール
yum install -y bzip2 make gcc openssl-devel readline-devel zlib-devel
rubyをインストール
rbenv install 2.3.1
gemでインストールした実行ファイルを実行するようにする
rbenv rehash
globalでrubyの実行versionを指定
rbenv global 2.3.1
最後に確認
ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768)
※ whichが無い場合はyum install -y which
which ruby
~/.rbenv/shims/ruby
which gem
~/.rbenv/shims/gem
参考文献
ruby 2.3.1をCentOS7に導入する。
http://qiita.com/Fendo181/items/d14ebfb148223c8e5ecb#rbenv-ruby-buildでrubyの導入環境を揃える