LoginSignup
9
6

More than 5 years have passed since last update.

Ruby on Rails 環境構築

Posted at

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

yumで必要なパッケージをインストールしていく

command
$ yum update
$ yum install gcc-c++ glibc-headers openssl openssl-devel readline libyaml-devel readline-devel zlib zlib-devel libxml2 libxslt libiconv

gitは必須です

command
$ yum install git

2. rbenvのインストール

rbenvとは、rubyのバージョン管理を簡単にするパッケージです。
gitで公開されているので、cloneします。

command
$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv

.bash_profile に下記を追記し、パスを通しましょう

.bash_profile
export RBENV_ROOT="~/.rbenv"
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"

3. ruby-buildのインストール

ruby-build は ruby のインストールを簡単にしてくれるパッケージです。
これもgitで公開してくれているので、cloneします。

command
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

4. rubyのインストール

いよいよ ruby のインストールです

公開されているrubyのバージョン一覧を確認します。

command
$ rbenv install -l

ここで install なんてないよーってエラーが出たら、ruby-buildが正しくインストールされていない場合があります。
3.をもう一度確認してください。

ちゃんとインストールしてるのにできないよー!!って方は、下記のコマンドを打ってみてください。

command
$ ~/rbenv/plugins/ruby-build/install.sh

rubyのバージョンを確認したら、インストールを行いましょう。
今回は、ruby 2.2.0 をインストールしてみます。

command
$ rbenv install -v 2.2.0

インストールした ruby を使用するように設定します。

command
$ rbenv rehash
$ rbenv global 2.2.0

ちゃんと設定されているか確認します。

command
$ rbenv -v

5. railsのインストール

いよいよ rails のインストールをしましょう。

command
$ gem update --system
$ gem install --no-ri --no-rdoc rails
$ gem install bundler

ここでnokogiriのエラーが出てはまりました。
下記の方法で解決
Ruby on Rails nokogiriエラーでbundle installできない

インストールできたか確認します。

command
$ rails rehash
$ rails -v
9
6
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
9
6