LoginSignup
210
213

More than 3 years have passed since last update.

rails環境構築(CentOS + ruby on rails)

Last updated at Posted at 2014-07-28

1.gitインストール

$ yum install git

2.パッケージインストール

$ yum install gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel

3.rubyインストール

rbenvインストール

$ git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv # <-※1
$ echo 'export RBENV_ROOT="/usr/local/rbenv"' >> /etc/profile # <-※2
$ echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /etc/profile
$ echo 'eval "$(rbenv init -)"' >> /etc/profile

※1 各ユーザで使用する場合は ~/.rbenv 配下
※2 各ユーザで使用する場合は ~/.bash_profile

いったんターミナル閉じたあとバージョン確認
$ rbenv --version

ruby-buildインストール

$ git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build

rubyインストール

インストール対象を確認しインストール
$ rbenv install -l
$ rbenv install -v 2.1.2
$ rbenv rehash
使用するバージョンを設定
$ rbenv global 2.1.2
バージョン確認
$ ruby -v

railsインストール

$ gem update --system
$ gem install -no-ri -no-rdoc rails
$ gem install bundler
$ rbenv rehash
バージョン確認
$ rails -v

4.railsサンプルアプリ作成

アプリ用ユーザ作成
$ useradd -m rails
サンプルアプリ作成
$ su - rails
$ cd ~
$ rails new sample --skip-bundle
Gemfileの設定(therubyracerの行をコメントイン)
$ cd ~/sample/
$ vim Gemfile
Gemfileより該当gemのインストール
$ bundle install --path=~/sample/vendor/bundle
WEBrick起動
$ rails s
http://ホスト名(or IP):3000にアクセス

"Welcome aboard"ページが表示されることを確認。

WEBrick停止
ctrl + c
210
213
4

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
210
213