[[FrontPage]] Ruby on Railsのインストールは、以下の手順で行う。 + Rubyのインストール + RubyGemsのインストール + Ruby on Railsのインストール + データベース(PostgreSQL)のインストール 私は、主にMac OSXとWindows 2000を使っているので、これらの機種へのインストール 手順を書き留める。 * Mac OSX へのRuby on Railsのインストール [#fc5bb6f4] Mac OSX 10.4からrubyがデフォルトでインストールされている。 rubyがインストールされているかどうかの確認は、ターミナルでruby -v と入力することで 分かる。 #pre{{ $ ruby -v ruby 1.8.2 (2004-12-25) [universal-darwin8.0] }} ** Mac OSXへのRubyGemsのインストール [#cde23a31] webサイト http://docs.rubygems.org/ にアクセスしたのだが、うまく接続できない。 そこで、 http://rubyforge.org/ にアクセスし、RubyGemsをダウンロードする。 ダウンロードしたRubyGemsのバージョンは、REL_0_9_0だった。 展開する場所は、ホームディレクトリ/local/にした。 RubyGemsのインストールは、展開した場所に移動し、ruby setup.rbと入力する。 このとき、スーパーユーザーの権限が必要なので、Mac OSXではsuが使えないので 以下のようにsudoで代用した。 #pre{{ $ cd ~/local/rubygems-0.9.0 $ sudo ruby setup.rb Password: ---> bin <--- bin ---> lib ---> lib/rbconfig <--- lib/rbconfig ---> lib/rubygems <--- lib/rubygems <--- lib ---> bin <--- bin ---> lib ---> lib/rbconfig <--- lib/rbconfig ---> lib/rubygems <--- lib/rubygems <--- lib rm -f InstalledFiles ---> bin mkdir -p /usr/bin/ install gem /usr/bin/ install gem_mirror /usr/bin/ install gem_server /usr/bin/ install gemlock /usr/bin/ install gemri /usr/bin/ install gemwhich /usr/bin/ install index_gem_repository.rb /usr/bin/ install update_rubygems /usr/bin/ <--- bin ---> lib mkdir -p /usr/lib/ruby/site_ruby/1.8/ install gemconfigure.rb /usr/lib/ruby/site_ruby/1.8/ install rubygems.rb /usr/lib/ruby/site_ruby/1.8/ install ubygems.rb /usr/lib/ruby/site_ruby/1.8/ ---> lib/rbconfig mkdir -p /usr/lib/ruby/site_ruby/1.8/rbconfig install datadir.rb /usr/lib/ruby/site_ruby/1.8/rbconfig <--- lib/rbconfig ---> lib/rubygems mkdir -p /usr/lib/ruby/site_ruby/1.8/rubygems install builder.rb /usr/lib/ruby/site_ruby/1.8/rubygems install cmd_manager.rb /usr/lib/ruby/site_ruby/1.8/rubygems install command.rb /usr/lib/ruby/site_ruby/1.8/rubygems install config_file.rb /usr/lib/ruby/site_ruby/1.8/rubygems install custom_require.rb /usr/lib/ruby/site_ruby/1.8/rubygems install dependency_list.rb /usr/lib/ruby/site_ruby/1.8/rubygems install doc_manager.rb /usr/lib/ruby/site_ruby/1.8/rubygems install format.rb /usr/lib/ruby/site_ruby/1.8/rubygems install gem_commands.rb /usr/lib/ruby/site_ruby/1.8/rubygems install gem_openssl.rb /usr/lib/ruby/site_ruby/1.8/rubygems install gem_runner.rb /usr/lib/ruby/site_ruby/1.8/rubygems install incremental_fetcher.rb /usr/lib/ruby/site_ruby/1.8/rubygems install installer.rb /usr/lib/ruby/site_ruby/1.8/rubygems install loadpath_manager.rb /usr/lib/ruby/site_ruby/1.8/rubygems install old_format.rb /usr/lib/ruby/site_ruby/1.8/rubygems install open-uri.rb /usr/lib/ruby/site_ruby/1.8/rubygems install package.rb /usr/lib/ruby/site_ruby/1.8/rubygems install remote_installer.rb /usr/lib/ruby/site_ruby/1.8/rubygems install rubygems_version.rb /usr/lib/ruby/site_ruby/1.8/rubygems install security.rb /usr/lib/ruby/site_ruby/1.8/rubygems install source_index.rb /usr/lib/ruby/site_ruby/1.8/rubygems install specification.rb /usr/lib/ruby/site_ruby/1.8/rubygems install timer.rb /usr/lib/ruby/site_ruby/1.8/rubygems install user_interaction.rb /usr/lib/ruby/site_ruby/1.8/rubygems install validator.rb /usr/lib/ruby/site_ruby/1.8/rubygems install version.rb /usr/lib/ruby/site_ruby/1.8/rubygems <--- lib/rubygems <--- lib As of RubyGems 0.8.0, library stubs are no longer needed. Searching $LOAD_PATH for stubs to optionally delete (may take a while)... ...done. No library stubs found. Successfully built RubyGem Name: sources Version: 0.0.1 File: sources-0.0.1.gem }} Mac OSXのrubyに不具合があるため、以下の処理が必要である。 #pre{{ $ sudo gem install fixrbconfig Bulk updating Gem source index for: http://gems.rubyforge.org Successfully installed fixrbconfig-1.2 $ sudo fixrbconfig ==================== /usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h does not exist. This probably means you haven't yet installed Xcode from the Tiger DVD. You won't be able to compile Ruby extensions without it. Please install it then rerun this program. }} おそらく、intel-macなのにpowerpcのヘッダを見に行っているのでエラーになったらしい。 そこで、/usr/lib/ruby/1.8/universal-darwin8.0をpowerpc-darwinにシンボリックリンクを張ることにした #pre{{ $ cd /usr/lib/ruby/1.8 $ sudo ln -s universal-darwin8.0 powerpc-darwin8.0 }} 再度、 #pre{{ $ sudo fixrbconfig ==================== This program will replace your rbconfig.rb , located in /usr/lib/ruby/1.8/powerpc-darwin8.0/rbconfig.rb Press enter continue or ctrl-c to abort. Backing up original rbconfig.rb in /usr/lib/ruby/1.8/powerpc-darwin8.0/rbconfig.rb.bak All Done! You should be able to compile C extensions now! }} ** Ruby on Railsのインストール [#vfec5e13] 最後にRuby on Railsをインストールする、RubyGemsを使うとgem install railsのコマンド1つで インストールが完了する。 #pre{{ $ sudo gem install rails --include-dependencies --version 1.1.2 Password: Successfully installed rails-1.1.2 Successfully installed rake-0.7.1 Successfully installed activesupport-1.3.1 Successfully installed activerecord-1.14.2 Successfully installed actionpack-1.12.1 Successfully installed actionmailer-1.2.1 Successfully installed actionwebservice-1.1.2 Installing ri documentation for rake-0.7.1... Installing ri documentation for activesupport-1.3.1... Installing ri documentation for activerecord-1.14.2... Installing ri documentation for actionpack-1.12.1... Installing ri documentation for actionmailer-1.2.1... Installing ri documentation for actionwebservice-1.1.2... Installing RDoc documentation for rake-0.7.1... Installing RDoc documentation for activesupport-1.3.1... Installing RDoc documentation for activerecord-1.14.2... Installing RDoc documentation for actionpack-1.12.1... Installing RDoc documentation for actionmailer-1.2.1... Installing RDoc documentation for actionwebservice-1.1.2... }} railsの動作確認は、 #pre{{ $ rails -v Rails 1.1.2 }} バージョン1.1.2が表示されればOKである。 * PostgreSQLのインストール [#i8536867] Mac OSX用のPkgインストーラが以下のサイトにある。 http://www.magic3.org/postgrex/ ここから、 - PostgreX(PostgreSQLのOSX用インストールパッケージ) - Magic Postgre(PostgreSQLフロントエンドプログラム) - PgPreference(PostgreSQLの起動停止を行うシステム環境設定プラグイン) をダウンロードし、インストールした。 * データベースアダプタのインストール [#uc28b2d1] データベースアダプタには、Ruby版とC版がある。 Ruby版のインストールは、以下のように行う。 #pre{{ $ sudo gem install postgres-pr Bulk updating Gem source index for: http://gems.rubyforge.org Successfully installed postgres-pr-0.4.0 }} C版のインストールは、以下のように行う。 #pre{{ $ sudo gem install ruby-postgres Bulk updating Gem source index for: http://gems.rubyforge.org Select which gem to install for your platform (universal-darwin8.0) 1. ruby-postgres 0.7.1.2006.04.06 (ruby) 2. ruby-postgres 0.7.1.2006.04.06 (mswin32) 3. ruby-postgres 0.7.1.2006.04.05 (mswin32) 4. ruby-postgres 0.7.1.2006.04.05 (ruby) 5. ruby-postgres 0.7.1.2005.12.21 (ruby) 6. ruby-postgres 0.7.1.2005.12.21 (mswin32) 7. ruby-postgres 0.7.1.2005.12.20 (mswin32) 8. ruby-postgres 0.7.1.2005.12.20 (ruby) 9. ruby-postgres 0.7.1.2005.12.19 (mswin32) 10. ruby-postgres 0.7.1.2005.12.19 (ruby) 11. ruby-postgres 0.7.1.2005.11.27 (mswin32) 12. ruby-postgres 0.7.1.2005.11.27 (ruby) 13. ruby-postgres 0.7.1.2005.11.26 (ruby) 14. ruby-postgres 0.7.1.2005.11.24 (ruby) 15. ruby-postgres 0.7.1.2005.11.24 (mswin32) 16. ruby-postgres 0.7.1.2005.11.23 (ruby) 17. Cancel installation > 1 Building native extensions. This could take a while... extconf.rb:6: command not found: pg_config --includedir extconf.rb:13: command not found: pg_config --libdir ERROR: While executing gem ... (RuntimeError) ERROR: Failed to build gem native extension. Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06 for inspection. Results logged to /usr/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06/gem_make.out }} PostgreSQLをパッケージを使ったため、pg_configが存在しなかったので失敗したようだ。 取りあえず、ruby版を使うことにする。 * コメント [#sff990f5] - ppzdnW <a href="http://xvqlfycwerat.com/">xvqlfycwerat</a>, [url=http://rbarukuwsbie.com/]rbarukuwsbie[/url], [link=http://squraxqxlnbg.com/]squraxqxlnbg[/link], http://sagwfmzfxkgw.com/ -- [[oztovsg]] &new{2012-07-25 (水) 19:00:48}; #comment 皆様のご意見、ご希望をお待ちしております。 #comment_kcaptcha