【rbenv】rubyの導入、操作方法【チラ裏】

よく忘れちゃうんで纏めておきます。

# 必要なパッケージ導入
yum install -y git gcc gcc-c++ openssl-devel readline-devel

# rbenvのインストール
cd /usr/local
git clone git://github.com/sstephenson/rbenv.git rbenv
git clone git://github.com/sstephenson/ruby-build.git rbenv/plugins/ruby-build

# 環境変数の設定
vi /etc/profile.d/rbenv.sh
=====================================
export RBENV_ROOT="/usr/local/rbenv"
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init --no-rehash -)"
=====================================
# 設定の反映
source /etc/profile.d/rbenv.sh

# 導入できるバージョンを確認
rbenv install --list

# rubyのインストール
rbenv install 2.2.2
rbenv global 2.2.2
rbenv rehash

# インストールしているrubyの確認
rbenv versions

# rubyの切り替え
rbenv global 2.7.0

# bundlerのインストール(-vでバージョン指定)
gem install bundler -v 1.16.5

【ruby】rails環境構築【rbenv】

サーバにrailsを導入する必要があったのです。
ただそれだけ。

パッケージのインストール

cd /usr/local
yum install -y git gcc gcc-c++ openssl-devel readline-devel
git clone git://github.com/sstephenson/rbenv.git rbenv
git clone git://github.com/sstephenson/ruby-build.git rbenv/plugins/ruby-build

環境変数の設定

vi /etc/profile.d/rbenv.sh
========================================
export RBENV_ROOT="/usr/local/rbenv"
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init --no-rehash -)"
========================================
source /etc/profile.d/rbenv.sh

rubyの導入

rbenv install --list

⇒必要なバージョンを確認
rbenv install 2.6.3
rbenv global 2.6.3
rbenv rehash

*取り敢えずruby 2.6.3を導入

railsとpassengerのインストール

gem update --system
gem install rails -v 6.0.0.rc2
gem install passenger
rbenv rehash

必要パッケージのインストール

yum install httpd libcurl-devel httpd-devel apr-devel apr-util-devel 
passenger-install-apache2-module

設定ファイル作成

vi /etc/httpd/conf.d/passenger.conf
=========================================================================================================================================
   LoadModule passenger_module /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/passenger-6.0.2/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /usr/local/rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/passenger-6.0.2
     PassengerDefaultRuby /usr/local/rbenv/versions/2.6.3/bin/ruby
   </IfModule>
=========================================================================================================================================