Ruby on Railsのインストール
今日からRuby on Railsを試してみたいと思います。
Web+DB PressのVol28に特集が乗っているので、これを参考に。
まずは、インストールですね。
RubyGemsを入れれば、Railsのインストールが簡単、と書いてあります。
ではRubyGemsのインストールから開始です。
RubyGemsのインストール
rubygems-0.8.11.zipをダウンロードして適当なディレクトリに展開
で、インストール実行
C:\>cd C:\Ruby\rubygems C:\Ruby\rubygems>ruby setup.rb
インストールが開始されました・・・が、あれ?
SSLEAY32.dllとzlib.dllというdllがないというエラーがでてしまいました。
Ruby-mswin32サイトによると、外部ライブラリが必要みたいです。
というわけで、Porting Libraries to Win32からopenssl-0.9.7b-1-mswin32.zipとzlib-1.1.4-1-mswin32.zipをダウンロードして、以下のdllをRuby本体のbinフォルダにコピー。
- zlib.dll
- ssleay32.dll
- libeay32.dll
再度SetUp実行すると、うまくいきました。
C:\Ruby\rubygems>ruby setup.rb
念のためバージョンを確認。
C:\Ruby\rubygems>gem -v 0.8.11
OKです。
Railsのインストール
そのままRailsのインストールを続けます。
RubyGemを使うと必要なライブラリを全部そろえてくれるとのこと。
gem install rails Attempting local installation of 'rails' Local gem file not found: rails*.gem Attempting remote installation of 'rails' Updating Gem source index for: http://gems.rubyforge.org ERROR: While executing gem ... (Gem::RemoteSourceException) Error fetching remote gem cache: getaddrinfo: no address associated with hostname.
む。やはりProxy経由だとダメか。
多分Proxyを指定するオプションがあるはずですので、Helpを確認。
C:\Ruby\rubygems>gem help install
pオプションでProxyのURLが指定できるみたいです。オプション付で再度実行します。
C:\Ruby\rubygems>gem install rails -p http://{proxy}:8080/
・・・だめです。タイムアウトしてしまいました。
ちょっと時間を置いてから実行。
お、今度はうまくいきそうです。依存ライブラリをインストールするかは質問は、すべて「Y」にしました。
C:\Ruby>gem install rails -p http://{proxy}:8080/ Attempting local installation of 'rails' Local gem file not found: rails*.gem Attempting remote installation of 'rails' Updating Gem source index for: http://gems.rubyforge.org Install required dependency rake? [Yn] Y Install required dependency activesupport? [Yn] Y Install required dependency activerecord? [Yn] Y Install required dependency actionpack? [Yn] Y Install required dependency actionmailer? [Yn] Y Install required dependency actionwebservice? [Yn] Y Successfully installed rails-0.13.1 Successfully installed rake-0.6.0 Successfully installed activesupport-1.1.1 Successfully installed activerecord-1.11.1 Successfully installed actionpack-1.9.1 Successfully installed actionmailer-1.0.1 Successfully installed actionwebservice-0.8.1 Installing RDoc documentation for rake-0.6.0... Installing RDoc documentation for activesupport-1.1.1... Installing RDoc documentation for activerecord-1.11.1... Installing RDoc documentation for actionpack-1.9.1... Installing RDoc documentation for actionmailer-1.0.1... Installing RDoc documentation for actionwebservice-0.8.1...
うまくいったようですけど、これってどこにインストールされたのでしょう?
とりあえずHelpで確認。
C:\Ruby\rubygems>gem help install (略) Defaults: --both --version '> 0' --rdoc --no-force --no-tes --install-dir C:/Ruby/sdk/1.8/lib/ruby/gems/1.8
書いてありました。iオプションでインストール先を変更できるようですね。
まあ今回はデフォルトで問題ないので、そのままにしておきます。
ちょっと手間取りましたが、これで必要なライブラリは全部インストールできたようです。かなり便利かも。
バージョンアップとかアンインストールとかどうやるんでしょう?それはおいおい調べることにします。
今日はここまで。RubyGemだけで終ってしまいました。