How to install Phusion Passenger

必要なgemパッケージをインストールする。

$ sudo `whence gem` install passenger

モジュールをインストールする。

$ sudo passenger-install-apache2-module

バイナリパッケージをインストールする。

$ sudo `whence passenger-install-apache2-module`

メッセージに従って作業する。

もう一度…。

$ sudo `whence passenger-install-apache2-module`

/etc/httpd/conf.d/passenger.conf を以下の内容で作成する*1

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.19
PassengerRuby /usr/local/bin/ruby

同ファイルに以下の行を追加する。

<VirtualHost *:80>
   ServerName www.yourhost.com                                                 
   # !!! Be sure to point DocumentRoot to 'public'!
   DocumentRoot /example/public
   <Directory /example/public>
      # This relaxes Apache security settings.                                  
      AllowOverride all
      # MultiViews must be turned off.                                          
      Options -MultiViews
   </Directory>
</VirtualHost>

apache の文法チェックを行う。

$ apachectl configtest

Rakeタスクでプリコンパイル済みのアセットを作成する。

$ bundle exec rake assets:precompile RAILS_ENV=production

httpdを再起動する。

$ service httpd restart

*1:$ passenger-install-apache2-module --snippet の出力