LoginSignup
1
3

More than 5 years have passed since last update.

まっさらなCentOS7にRailsの開発環境を構築する

Last updated at Posted at 2017-08-30

執筆日

2017/08/30

はじめに

  • Windows 10 Pro v1703 b15063.540
  • VirtualBox 5.1.26 r117224 (Qt5.6.2)
    • Extension Pack 5.1.26 r117224
  • Vagrant 1.9.6
    • vagrant-share 1.1.9, system
    • vagrant-vbguest 0.14.2

以上の環境に構築。
バージョンの違いにより、動かない場合あり。

VagrantでCentOS7を用意する

boxをダウンロードする

1.適当なディレクトリを作成。
2.以下のコマンドを実行。Vagrantfileが作成される。

vagrant init centos/7

3.必要があれば、Vagrantfileを編集。
4.以下のコマンドを実行。初回なのでダウンロードが発生する。

vagrant up

sshで接続出来る様にする

1.以下のコマンドを実行。

vagrant ssh-config --host [ホスト名] >> [.sshのパス]/config

2.以下のコマンドで接続。

ssh [ホスト名]

Rubyのセットアップ

rbenvとruby-buildをインストールする

1.事前準備。

$ sudo yum -y update kernel
$ sudo yum -y install kernel-devel git openssl-devel readline-devel zlib-devel gcc gcc-c++

2.gitからクローンして持ってくる。

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

3.以下のコマンドを実行。

$ cd ~/.rbenv/plugins/ruby-build
$ sudo ./install.sh

4.設定を追記。

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile

rbenvでRubyをインストールする

1.以下のコマンドを実行。なかなか終わらないが根気よく待つ。

$ rbenv install 2.3.3

Rubyを使える様にする

1.以下のコマンドを実行。

$ rbenv global 2.3.3

Railsのセットアップ

gemをインストールする

1.以下のコマンドを実行。

$ gem install bundler
$ gem install rails

以上で、Railsが使える状態になっているはず。

おわりに

Ansibleとかで自動化したい。

1
3
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
1
3