Passengerを使ってEc2にRailsアプリを公開しましょう。
gemで簡単インストール。
gem install passenger
次にpassenger-install-apache2-moduleを実行し、Apacheモジュールのビルドとインストールを行いましょう。
passenger-install-apache2-module
このスクリプトは対話形式で処理を実行します。
画面の指示に従って進めれば容易に処理を完了できます。
ビルドに成功すると、Passengerを組み込むためのhttpd.confの設定が表示されるのでコピーしておきましょう。
Deploying a Ruby on Rails application: an example Suppose you have a Ruby on Rails application in /somewhere. Add a virtual host to your Apache configuration file, and set its DocumentRoot to /somewhere/public, like this: <VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /somewhere/public # <-- be sure to point to 'public'! </VirtualHost>
-
- Apacheの設定
passenger-install-apache2-moduleの最終段階の画面で
"Please edit your Apache configuration file, and add these lines:"
という指示とともにhttpd.confに追加すべき設定内容が表示されます。
これに合わせてhttpd.confを修正します。
vi /etc/httpd/conf/httpd.conf LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-1.0.1/ext/apache2/mod_passenger.so RailsSpawnServer /usr/lib/ruby/gems/1.8/gems/passenger-1.0.1/bin/passenger-spawn-server RailsRuby /usr/bin/ruby1.8 # developmentモードで動かす場合は忘れずに。 RailsEnv development
あとは、ApacheのDocumentRootを
$RAILS_ROOT/publicに設定すれば、
自動的にRailsアプリケーションが認識されます。
詳しくはこちら。
http://redmine.jp/tech_note/apache-passenger/