約100日ぶりの更新です。
RailsとiOS/Androidアプリとクラウド3点セットのお仕事が増えてきましたので、少しNode.jsから離れて、更新を続けようと思います。
Moutain LionにRailsをインストールしたときの作業のログです。
Rubyのバージョン管理ツールにrbenvを使用しています。
事前準備
- AppStoreでXcode 4.5.1 をインストールしておく
- Xcode 4.5.1の設定からCommand Line Tools をインストールしておく
Homebrewをインストールする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)" | |
$ brew doctor | |
Your system is raring to brew. |
rbenvをインストールする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ brew install rbenv |
.bash_profileを編集して以下の一行を追加します。
$ vim ~/.bash_profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi |
再読込を忘れずに
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ source ~/.bash_profile |
ruby-buildをインストール
rbenv install -l でインストール可能なバージョンのリストが表示されればOKです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ brew install ruby-build | |
$ rbenv install -l | |
Available versions: | |
1.8.6-p383 | |
1.8.6-p420 | |
1.8.7-p249 | |
1.8.7-p302 | |
... | |
1.9.3-p0 | |
1.9.3-p125 | |
1.9.3-p194 | |
1.9.3-preview1 | |
… |
Rubyをインストールする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rbenv install 1.9.3-p194 | |
$ rbenv versions | |
1.9.3p194 | |
$ rbenv global 1.9.3-p194 | |
$ rbenv rehash | |
$ ruby -v | |
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0] | |
$ which ruby | |
/Users/inoue/.rbenv/shims/ruby |
使用しているrubyのバージョンが1.9.3-p194でパスが変更されていればOK。
Railsをインストールする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gem install rails | |
$ source ~/.bash_profile | |
$ rails -v | |
Rails 3.2.8 |
Railsアプリを作成する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails new helloworld | |
$ cd helloworld/ | |
$ rails s | |
=> Booting WEBrick | |
=> Rails 3.2.8 application starting in development on http://0.0.0.0:3000 | |
=> Call with -d to detach | |
=> Ctrl-C to shutdown server | |
[2012-10-14 12:51:43] INFO WEBrick 1.3.1 | |
[2012-10-14 12:51:43] INFO ruby 1.9.3 (2012-04-20) [x86_64-darwin12.2.0] | |
[2012-10-14 12:51:43] INFO WEBrick::HTTPServer#start: pid=28949 port=3000 |
ブラウザから http://localhost:3000/ にアクセスして以下の画面が表示されたRailsのインストールは完了です。