LoginSignup
0
0

More than 5 years have passed since last update.

ruby 2.3.1をCentOS7にインストールする方法(CentOSのminimal環境に対応)

Last updated at Posted at 2016-11-06

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の導入環境を揃える

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0