Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gaspanik
Created September 30, 2012 14:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaspanik/3806988 to your computer and use it in GitHub Desktop.
Save gaspanik/3806988 to your computer and use it in GitHub Desktop.
Install: Install RoR on 10.8.x

Setting up a Ruby On Rails environment on Mountain Lion

http://dean.io/blog/setting-up-a-ruby-on-rails-development-environment-on-mountain-lion

こちらの手順を参考にRVMの前までは準備をしておく

RVMのインストール

RVMは、そのまんまRubyのバージョンマネージャー。詳しいことは以下を

RVM: Ruby Version Manager - RVM Ruby Version Manager - Documentation(http://rvm.io/)

インストールは以下のコマンドを実行(Rubyを一緒に入れるとかオプションもある)

curl -L get.rvm.io | bash -s stable

https://github.com/wayneeseguin/rvm#installation

--

Installing RVM to /Users/ユーザ名/.rvm/

  • Adding rvm PATH line to /Users/ユーザ名/.bashrc /Users/ユーザ名/.zshrc.
  • Adding rvm loading line to /Users/ユーザ名/.bash_login /Users/ユーザ名/.zlogin.

RVM: Shell scripts enabling management of multiple ruby environments.

RTFM: https://rvm.io/

HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)

Cheatsheet: http://cheat.errtheblog.com/s/rvm/

Screencast: http://screencasts.org/episodes/how-to-use-rvm

In case of any issues read output of 'rvm requirements' and/or 'rvm notes'

Installation of RVM in /Users/ユーザ名/.rvm/ is almost complete :

To start using RVM you need to run source /Users/ユーザ名/.rvm/scripts/rvm in all your open shell windows, in rare cases you need to reopen all shell windows.

--

以上の画面が出てきたら、次のコマンド実行

    source /Users/ユーザ名/.rvm/scripts/rvm

これでRVMが使えるはず

RVM でRubyを入れる前にHomebrewでいろいろ入れておく

まずは、Homebrewをアップデート

brew update

gcc-4.2は「dupes」の中にあるので以下のコマンドを実行

brew tap homebrew/dupes

で、インストール

brew install autoconf automake apple-gcc42

あと、これも必要になる

brew install libksba

おしまい

Rubyのインストール

RVMでRubyの最新版をインストール。インストールする際にシステムとぶつかるとか依存関係がどうしたとか出てくるので、ちゃんと読むこと

先にRVMで「openssl」を入れておく(後から入れるとリコンパイルで面倒)

rvm pkg install openssl

で、Rubyをインストール

rvm install 1.9.3

インストールが終わったら、RVMのデフォルトを指定

rvm use 1.9.3 --default

Rails ほかをインストール

gem install rails bundler

Git をHomebrewでインストール

GCC、GitをHomebrewで入れるとパスが後先逆になってしまい、「brew doctor」でもWarningになるのでパスをちゃんと読み込まれるように修正する。

自分のホームディレクトリにある「~/.bash_login」の先頭行とかに以下をペースト(それ以外に、/etc/paths の順番変えるとかでもまぁ)

export PATH=/usr/local/bin:$PATH

※この辺は使ってるシェルで異なるので自分の環境に適宜置き換える

で、以下のコマンドを実行

source ~/.bash_login

「brew doctor」を実行して問題ないことを確認

Railsが動いてるどうか確認がてら

適当にフォルダを作って

mkdir ~/Path/to/directory

railsコマンドで作ったディレクトリにファイルを用意する

rails new ~/Path/to/directory

わらわらと必要なファイル一式が入る。で、内部のサーバを立ち上げてブラウザでアクセス

rails server

http://localhost:3000」につないでみる。サーバは、「Ctrl+C」で終了できる。

あとは、がんばりましょう。以下、おまけ

POW(Server)のインストール

37signalsが公開しているサーバ(http://pow.cx/)

Railsは「rails server」で内部のサーバを実行できるけど、立ち上げっぱなしのサーバを作るならこれが簡単。ただし、先にApacheとか立ち上げてるとポートの初期設定が80番でぶつかるので、設定を変えるとかしないとだめ。

インストール

以下のコマンドを実行すればよい(アンインストールは最後に)

curl get.pow.cx | sh

--

*** Installing Pow 0.4.0...

*** Installing local configuration files...

/Users/ユーザ名/Library/LaunchAgents/cx.pow.powd.plist

*** Installing system configuration files as root...

Password:

/Library/LaunchDaemons/cx.pow.firewall.plist

/etc/resolver/dev

*** Starting the Pow server...

*** Performing self-test...

*** Installed

For troubleshooting instructions, please see the Pow wiki: https://github.com/37signals/pow/wiki/Troubleshooting

To uninstall Pow, curl get.pow.cx/uninstall.sh | sh

--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment