RubyGemsでRailsをインストール

/usr/bin/rails にすでにRails 2.3.5が入っている。


rubygems を使って rails をインストール

$ sudo gem install rails -y
mkdir -p /opt/local/lib/ruby/site_ruby/1.8/rbconfig
install -c -m 0644 rbconfig/datadir.rb /opt/local/lib/ruby/site_ruby/1.8/rbconfig/datadir.rb
mkdir -p /opt/local/lib/ruby/site_ruby/1.8/rubygems
install -c -m 0644 rubygems/builder.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/builder.rb
install -c -m 0644 rubygems/command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/command.rb
install -c -m 0644 rubygems/command_manager.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb
mkdir -p /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands
install -c -m 0644 rubygems/commands/build_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/build_command.rb
install -c -m 0644 rubygems/commands/cert_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/cert_command.rb
install -c -m 0644 rubygems/commands/check_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/check_command.rb
install -c -m 0644 rubygems/commands/cleanup_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/cleanup_command.rb
install -c -m 0644 rubygems/commands/contents_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/contents_command.rb
install -c -m 0644 rubygems/commands/dependency_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/dependency_command.rb
install -c -m 0644 rubygems/commands/environment_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/environment_command.rb
install -c -m 0644 rubygems/commands/fetch_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/fetch_command.rb
install -c -m 0644 rubygems/commands/generate_index_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/generate_index_command.rb
install -c -m 0644 rubygems/commands/help_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/help_command.rb
install -c -m 0644 rubygems/commands/install_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/install_command.rb
install -c -m 0644 rubygems/commands/list_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/list_command.rb
install -c -m 0644 rubygems/commands/lock_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/lock_command.rb
install -c -m 0644 rubygems/commands/mirror_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/mirror_command.rb
install -c -m 0644 rubygems/commands/outdated_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/outdated_command.rb
install -c -m 0644 rubygems/commands/pristine_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/pristine_command.rb
install -c -m 0644 rubygems/commands/query_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/query_command.rb
install -c -m 0644 rubygems/commands/rdoc_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/rdoc_command.rb
install -c -m 0644 rubygems/commands/search_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/search_command.rb
install -c -m 0644 rubygems/commands/server_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/server_command.rb
install -c -m 0644 rubygems/commands/sources_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/sources_command.rb
install -c -m 0644 rubygems/commands/specification_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/specification_command.rb
install -c -m 0644 rubygems/commands/uninstall_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/uninstall_command.rb
install -c -m 0644 rubygems/commands/unpack_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/unpack_command.rb
install -c -m 0644 rubygems/commands/update_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/update_command.rb
install -c -m 0644 rubygems/commands/which_command.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/commands/which_command.rb
install -c -m 0644 rubygems/config_file.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/config_file.rb
install -c -m 0644 rubygems/custom_require.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb
install -c -m 0644 rubygems/dependency.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/dependency.rb
install -c -m 0644 rubygems/dependency_installer.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/dependency_installer.rb
install -c -m 0644 rubygems/dependency_list.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/dependency_list.rb
mkdir -p /opt/local/lib/ruby/site_ruby/1.8/rubygems/digest
install -c -m 0644 rubygems/digest/digest_adapter.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/digest/digest_adapter.rb
install -c -m 0644 rubygems/digest/md5.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/digest/md5.rb
install -c -m 0644 rubygems/digest/sha1.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/digest/sha1.rb
install -c -m 0644 rubygems/digest/sha2.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/digest/sha2.rb
install -c -m 0644 rubygems/doc_manager.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/doc_manager.rb
install -c -m 0644 rubygems/exceptions.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/exceptions.rb
mkdir -p /opt/local/lib/ruby/site_ruby/1.8/rubygems/ext
install -c -m 0644 rubygems/ext/builder.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/ext/builder.rb
install -c -m 0644 rubygems/ext/configure_builder.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/ext/configure_builder.rb
install -c -m 0644 rubygems/ext/ext_conf_builder.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/ext/ext_conf_builder.rb
install -c -m 0644 rubygems/ext/rake_builder.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/ext/rake_builder.rb
install -c -m 0644 rubygems/ext.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/ext.rb
install -c -m 0644 rubygems/format.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/format.rb
install -c -m 0644 rubygems/gem_open_uri.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/gem_open_uri.rb
install -c -m 0644 rubygems/gem_openssl.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/gem_openssl.rb
install -c -m 0644 rubygems/gem_path_searcher.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/gem_path_searcher.rb
install -c -m 0644 rubygems/gem_runner.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb
mkdir -p /opt/local/lib/ruby/site_ruby/1.8/rubygems/indexer
install -c -m 0644 rubygems/indexer/abstract_index_builder.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/indexer/abstract_index_builder.rb
install -c -m 0644 rubygems/indexer/marshal_index_builder.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/indexer/marshal_index_builder.rb
install -c -m 0644 rubygems/indexer/master_index_builder.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/indexer/master_index_builder.rb
install -c -m 0644 rubygems/indexer/quick_index_builder.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/indexer/quick_index_builder.rb
install -c -m 0644 rubygems/indexer.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/indexer.rb
install -c -m 0644 rubygems/install_update_options.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/install_update_options.rb
install -c -m 0644 rubygems/installer.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/installer.rb
install -c -m 0644 rubygems/local_remote_options.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/local_remote_options.rb
install -c -m 0644 rubygems/old_format.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/old_format.rb
install -c -m 0644 rubygems/open-uri.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/open-uri.rb
install -c -m 0644 rubygems/package.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/package.rb
install -c -m 0644 rubygems/platform.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/platform.rb
install -c -m 0644 rubygems/remote_fetcher.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb
install -c -m 0644 rubygems/remote_installer.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb
install -c -m 0644 rubygems/requirement.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/requirement.rb
install -c -m 0644 rubygems/rubygems_version.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/rubygems_version.rb
install -c -m 0644 rubygems/security.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/security.rb
install -c -m 0644 rubygems/server.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/server.rb
install -c -m 0644 rubygems/source_index.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb
install -c -m 0644 rubygems/source_info_cache.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/source_info_cache.rb
install -c -m 0644 rubygems/source_info_cache_entry.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/source_info_cache_entry.rb
install -c -m 0644 rubygems/specification.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/specification.rb
install -c -m 0644 rubygems/timer.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/timer.rb
install -c -m 0644 rubygems/uninstaller.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/uninstaller.rb
install -c -m 0644 rubygems/user_interaction.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/user_interaction.rb
install -c -m 0644 rubygems/validator.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/validator.rb
install -c -m 0644 rubygems/version.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/version.rb
install -c -m 0644 rubygems/version_option.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/version_option.rb
install -c -m 0644 rubygems.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb
install -c -m 0644 ubygems.rb /opt/local/lib/ruby/site_ruby/1.8/ubygems.rb
cp gem /tmp/gem
install -c -m 0755 /tmp/gem /opt/local/bin/gem
rm /tmp/gem
cp update_rubygems /tmp/update_rubygems
install -c -m 0755 /tmp/update_rubygems /opt/local/bin/update_rubygems
rm /tmp/update_rubygems
Removing old RubyGems RDoc and ri...
Installing rubygems-0.9.5 ri into /opt/local/lib/ruby/gems/1.8/doc/rubygems-0.9.5/ri...
Installing rubygems-0.9.5 rdoc into /opt/local/lib/ruby/gems/1.8/doc/rubygems-0.9.5/rdoc...
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.

確認とテスト

(bashではなくてtcshを使っているなら、あらかじめrehashが必要。)

$ rails -v
Rails 1.2.5
$ cd
$ rails test
      create  
      create  app/controllers
      create  app/helpers
      create  app/models
      create  app/views/layouts
      create  config/environments
      create  config/initializers
      create  config/locales
      create  db
      create  doc
      create  lib
      create  lib/tasks
      create  log
      create  public/images
      create  public/javascripts
      create  public/stylesheets
      create  script/performance
      create  test/fixtures
      create  test/functional
      create  test/integration
      create  test/performance
      create  test/unit
      create  vendor
      create  vendor/plugins
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  Rakefile
      create  README
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  config/database.yml
      create  config/routes.rb
      create  config/locales/en.yml
      create  db/seeds.rb
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/new_rails_defaults.rb
      create  config/initializers/session_store.rb
      create  config/environment.rb
      create  config/boot.rb
      create  config/environments/production.rb
      create  config/environments/development.rb
      create  config/environments/test.rb
      create  script/about
      create  script/console
      create  script/dbconsole
      create  script/destroy
      create  script/generate
      create  script/runner
      create  script/server
      create  script/plugin
      create  script/performance/benchmarker
      create  script/performance/profiler
      create  test/test_helper.rb
      create  test/performance/browsing_test.rb
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/index.html
      create  public/favicon.ico
      create  public/robots.txt
      create  public/images/rails.png
      create  public/javascripts/prototype.js
      create  public/javascripts/effects.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/controls.js
      create  public/javascripts/application.js
      create  doc/README_FOR_APP
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log

確認とテスト2

$ cd test
$ script/server webrick
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-09-29 17:14:37] INFO  WEBrick 1.3.1
[2010-09-29 17:14:37] INFO  ruby 1.8.7 (2009-06-12) [universal-darwin10.0]
[2010-09-29 17:14:38] INFO  WEBrick::HTTPServer#start: pid=90659 port=3000

ブラウザで確認

Safari を起動して http://localhost:3000/ にアクセス。

以下の画面が出たらOK

127.0.0.1 - - [22/Nov/2007:16:29:24 JST] "GET / HTTP/1.1" 200 7552 
- -> / 
127.0.0.1 - - [22/Nov/2007:16:29:24 JST] "GET /favicon.ico HTTP/1.1" 200 0 
http://localhost:3000/ -> /favicon.ico 
127.0.0.1 - - [22/Nov/2007:16:29:24 JST] "GET /javascripts/prototype.js HTTP/1.1" 200 71260 
http://localhost:3000/ -> /javascripts/prototype.js 
127.0.0.1 - - [22/Nov/2007:16:29:24 JST] "GET /javascripts/effects.js HTTP/1.1" 200 38200 
http://localhost:3000/ -> /javascripts/effects.js 
127.0.0.1 - - [22/Nov/2007:16:29:24 JST] "GET /images/rails.png HTTP/1.1" 200 1787 
http://localhost:3000/ -> /images/rails.png

return