Railsのインストール

《関連》
 ・Ruby
 ・Rubyのインストール
 ・Ruby on Rails

【Railsのインストール】

gem install rails --include-dependencies
※rdocがいらない時は gem install rails --no-rdoc 。(rdocのインストールでエラーになる場合がある時とか)

(補足)
 Windowsにインストールする場合、以下のエラーが出る事があるので
 http://www.kaoriya.net/#LIBICONV 等から各dllを取得してruby/bin に設置

 SSLEAY32.dllが見つからなかったため、このアプリケーションを開始できませんでした。
 zlib.dllが見つからなかったため、このアプリケーションを開始できませんでした。
 iconv.dllが見つからなかったため、このアプリケーションを開始できませんでした。

【Mysqlドライバのインストール】

gem install mysql

【railsプロジェクトの作成】

rails -d mysql example

※mySQLを使用する場合

【database.ymlの編集】

development:
  adapter: mysql
  database: example_development
  username: xxxxx
  password: xxxxx
  host: localhost
  encoding: utf8

【rakeコマンドでデータベースを作成】

rake db:create:all

【モデル、コントローラの生成】

ruby script/generate scaffold employee id:integer name:string age:integer

【rakeコマンドでDBをmigrate】

rake db:migrate

【サーバ(WEBrick)の起動】

ruby script/server

※ WEBrickを使わずにApacheでCGIとして動かす場合は dispatch.rb に mod_rewriteする
(現在はCGIとしての利用は推奨されていないらしい。Passengerなどを使う。)

【passengerのインストール】

gem install passenger
passenger-install-apache2-module



 --------------------------------------------
The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

  LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
  PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.11
  PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!

Press ENTER to continue.

 --------------------------------------------
Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:

  <VirtualHost *:80>
     ServerName www.yourhost.com
     DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!
     &lt;Directory /somewhere/public&gt;
        AllowOverride all              # <-- relax Apache security settings
        Options -MultiViews            # <-- MultiViews must be turned off
     &lt;/Directory&gt;
  &lt;/VirtualHost&gt;

And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:

  /Library/Ruby/Gems/1.8/gems/passenger-2.2.11/doc/Users guide Apache.html

Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
http://www.modrails.com/

Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.

※httpd.confを上記で言われた通りに編集する。


トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2010-05-23 (日) 14:26:28 (5087d)