2015年7月13日月曜日

awsのec2インスタンス作成時にruby2.2.2をインストールするユーザーデータ

完全にメモですが、awsでec2インスタンス作るときに、
ruby2.2.2をrbenvで入れてある状態にするユーザーデータです。

#!/bin/bash
yum update -y
yum install -y git
yum install -y gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel libffi-devel libxml2 libxslt libxml2-devel libxslt-devel sqlite-devel mysql-devel
yum install -y patch
 
cd /usr/local
git clone https://github.com/sstephenson/rbenv.git
mkdir -p /usr/local/rbenv/plugins
cd /usr/local/rbenv/plugins
git clone https://github.com/sstephenson/ruby-build.git
 
cat << EOF >> /etc/profile.d/rbenv.sh
export RBENV_ROOT=/usr/local/rbenv
export PATH="\$RBENV_ROOT/bin:\$PATH"
eval "\$(rbenv init -)"
EOF
 
source /etc/profile.d/rbenv.sh
rbenv install -f 2.2.2
rbenv rehash
rbenv global 2.2.2
rbenv version
最後にrbenv versionを入れてないと、最初にログインした時のruby -vが2.2.2にならなかった

参考URL
http://hivecolor.com/id/129

0 件のコメント:

コメントを投稿