webネタ

技術系ブログ。web系SE。1988。♂。@rhong_

centos6にruby1.9.3いれるシェル

rbenv+ruby-build

#!/bin/bash

set -ex

## rbenv

### preinstall
yum -y install gcc kernel-devel zlib-devel openssl-devel readline-devel curl-devel libyaml-devel sqlite-devel

### cwd
cd /usr/local/share

### download
git clone git://github.com/sstephenson/rbenv.git

### install
cat << EOT > /etc/profile.d/rbenv.sh
export PATH="/usr/local/share/rbenv/bin:$PATH"
export RBENV_VERSION="1.9.3-p194"
export RBENV_DIR=/usr/local/share/rbenv
export RBENV_ROOT=/usr/local/share/rbenv
eval "\$(rbenv init -)"
EOT

chmod 755 /etc/profile.d/rbenv.sh
. /etc/profile.d/rbenv.sh

## ruby-build

### cwd
cd /usr/local/src

### download
git clone git://github.com/sstephenson/ruby-build.git

### install
cd ruby-build
./install.sh

## ruby 1.9.3

### install
rbenv install 1.9.3-p194
rbenv rehash

### complete!
ruby -v
which ruby
gem -v
which gem