Passengerを使ってみた

http://www.modrails.com/

Passengerとはつまるところmod_railsです。暇なので、とりあえず会社のCentOS 5にインストール。

1. Open a terminal,and type:
gem install passenger

2. Type:
passenger-install-apache2-module

And follow the instructions.

http://www.modrails.com/install.html

公式に書いてある手順は上記だけ。とりあえずなんも考えずにやります。

# gem install passenger
# passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer,v2.0.3.

This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:n
 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.

とりあえず1を入力してエンター。

Press Enter to continue, or Ctrl-C to abort.
1
Checking for required software...
...(略)...
Compiling and installing Apache 2 module...
...(略)...
--------------------------------------------
The Apache 2 module was successfully installed.

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

   LoadModule passenger_module /usr/lib64/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so
   PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-2.0.3
   PassengerRuby /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.

エンター。

Press ENTER to continue.


--------------------------------------------
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
   </VirtualHost>

And that's it! You may also want to check the Users Guide for security and
optimization tips and other useful information:n
  /usr/lib64/ruby/gems/1.8/gems/passenger-2.0.3/doc/Users guide.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.

んで上にあった

   LoadModule passenger_module /usr/lib64/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so
   PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-2.0.3
   PassengerRuby /usr/bin/ruby

これをhttpd.confに貼り付け。あとは適当にVirtualHostの設定をしてアクセス。するとエラーが。


We're sorry, but something went wrong.

We've been notified about this issue and we'll take a look at it shortly.

原因を調べたら、どうやらRailsEnvがproductionのようです。

RailsEnv development

上記をhttpd.confに記述すればOK。ちなみにRAILS_ROOT/public/.htaccessに書いたけどそれでは動きませんでした。

うーむ、素晴らしい。とにかく楽だ。