LoginSignup
7
8

More than 5 years have passed since last update.

VagrantのCentOSにRails環境を構築

Posted at

==============================

参考

ssh

$ vagrant ssh

gitを入れる

$ sudo yum -y install git

CentOSにrbenvを入れる

rbenvを入れる

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

パス、環境変数の設定

# PATH に追加
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

# .bash_profile に追加
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

# 上記設定の再読み込み
$ exec $SHELL -l

ruby-build を インストール(clone)する

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

rbenv経由でRubyを入れる

ruby の最新版を確認

$ rbenv install --list

rubyのインストール

$ rbenv install -v 2.0.0-p481

rbenv環境確認

再読み込み

$ rbenv rehash

インストールされているruby一覧を確認

$ rbenv versions
* system (set by /home/vagrant/.rbenv/version)
  2.0.0-p481

グローバルに設定

$ rbenv global 2.0.0-p481
$ ruby -v

Railsのインストール

gemのアップデート

$ gem update --system

Bundlerのインストール

$ gem install bundler

Railsを入れる

$ gem install rails --no-ri --no-rdoc

rehashはめんどくさいので自動化

$ gem install rbenv-rehash

これ使わないと、gemをインストールするたびにrbenv rehashする必要があるらしい

反映

$ rbenv rehash

WebServer(httpd)のインストール

httpd

$ sudo yum -y install httpd
$ sudo service httpd start
$ sudo chkconfig httpd on

# ファイアウォールを切る
$ sudo service iptables stop
$ sudo chkconfig iptables off

フォルダ共有(シンボリックリンク)

$ sudo rm -rf /var/www/html
$ sudo ln -fs /vagrant /var/www/html
7
8
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
7
8