CentOSにRubyをインストールしてみる。
rbenvインストール
■gitインストール
sudo yum install git
[testuser@localhost ~]$ sudo yum install git : 完了しました!
■rbenv取得
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
[testuser@localhost ~]$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv Initialized empty Git repository in /home/testuser/.rbenv/.git/ remote: Enumerating objects: 2744, done. remote: Total 2744 (delta 0), reused 0 (delta 0), pack-reused 2744 Receiving objects: 100% (2744/2744), 515.63 KiB | 624 KiB/s, done. Resolving deltas: 100% (1720/1720), done.
■rbenvパス設定/有効化
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile ~/.rbenv/bin/rbenv init source ~/.bash_profile
[testuser@localhost ~]$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile [testuser@localhost ~]$ ~/.rbenv/bin/rbenv init # Load rbenv automatically by appending # the following to ~/.bash_profile: eval "$(rbenv init -)" [testuser@localhost ~]$ source ~/.bash_profile
■動作確認
rbenv -v
[testuser@localhost ~]$ rbenv -v rbenv 1.1.1-39-g59785f6
ruby-buildインストール
■ruby-build取得
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
[testuser@localhost ~]$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build Initialized empty Git repository in /home/testuser/.rbenv/plugins/ruby-build/.git/ remote: Enumerating objects: 51, done. remote: Counting objects: 100% (51/51), done. remote: Compressing objects: 100% (34/34), done. remote: Total 9642 (delta 19), reused 43 (delta 11), pack-reused 9591 Receiving objects: 100% (9642/9642), 2.02 MiB | 1.25 MiB/s, done. Resolving deltas: 100% (6307/6307), done.
■ruby-buildインストール
sudo ~/.rbenv/plugins/ruby-build/install.sh
[testuser@localhost ~]$ sudo ~/.rbenv/plugins/ruby-build/install.sh
■動作確認
rbenv install -l
[testuser@localhost ~]$ rbenv install -l : truffleruby-1.0.0-rc9
Rubyインストール
■openssl readline zlibインストール
sudo yum install -y openssl-devel readline-devel zlib-devel
[testuser@localhost ~]$ sudo yum install -y openssl-devel readline-devel zlib-devel : 完了しました!
■Rubyインストール
rbenv install 2.4.1
[testuser@localhost ~]$ rbenv install 2.4.1 Downloading ruby-2.4.1.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2 Installing ruby-2.4.1... BUILD FAILED (CentOS release 6.10 (Final) using ruby-build 20190130) Inspect or clean up the working tree at /tmp/ruby-build.20190203193650.7712 Results logged to /tmp/ruby-build.20190203193650.7712.log Last 10 log lines: checking for ruby... false checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking target system type... i686-pc-linux-gnu checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/tmp/ruby-build.20190203193650.7712/ruby-2.4.1': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
→ BUILD FAILED となった。gccをインストールしていないのが原因と思われる。
gccをインストール
sudo yum install gcc
[testuser@localhost ~]$ sudo yum install gcc : 完了しました!
再度rubyをインストール
[testuser@localhost ~]$ rbenv install 2.4.1 Downloading ruby-2.4.1.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2 Installing ruby-2.4.1... Installed ruby-2.4.1 to /home/testuser/.rbenv/versions/2.4.1何も出ないのでOKか?
■パス設定
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
source ~/.bash_profile
[testuser@localhost ~]$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile [testuser@localhost ~]$ source ~/.bash_profile
■バージョン設定
rbenv global 2.4.1
[testuser@localhost ~]$ rbenv global 2.4.1
■動作確認
ruby -v
[testuser@localhost ~]$ ruby -v ruby 2.4.1p111 (2017-03-22 revision 58053) [i686-linux]
[Rudy]
0 件のコメント:
コメントを投稿