アーカイブ

‘apache’ タグのついている投稿

Passenger(mod_rails for Apache)を試す

2008 年 4 月 15 日 コメント 16,551 件

Passenger(mod_rails for Apache)をインストールしてみました。
試した環境は

  • MaxOSX Tiger
  • Apache2.2(MacPortsでインストール済み)

です。

apacheが複数インストールされている場合は対象のApache apxsを指定する必要があるようです。

> export APXS2=/opt/local/apache2/bin/apxs

まずgemでインストールして、

> sudo gem install passenger -y

mod_railsをインストール。

> sudo passenger-install-apache2-module

ありゃ。

### In ext/apache2:
g++ -flat_namespace -bundle -undefined dynamic_lookup Utils.o Logging.o Configuration.o Hooks.o mod_passenger.o -fPIC -o mod_passenger.so   -lstdc++ -lpthread ../boost/src/libboost_thread.a -L/opt/local/lib -lapr-1
/usr/bin/ld: flag: -undefined dynamic_lookup can't be used with MACOSX_DEPLOYMENT_TARGET environment variable set to: 10.1
collect2: ld returned 1 exit status
rake aborted!
Command failed with status (1): [g++ -flat_namespace -bundle -undefined dyn...]
/opt/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/rakefile:132
(See full trace by running task with --trace)

明らかに怪しいので MACOSX_DEPLOYMENT_TARGET を設定してリトライ。

> export MACOSX_DEPLOYMENT_TARGET=10.4
> sudo passenger-install-apache2-module

とおった。

The Apache 2 module was successfully installed.

以下のように表示されるので、httpd.confに設定を追加。

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

LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/ext/apache2/mod_passenger.so
RailsSpawnServer /opt/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/bin/passenger-spawn-server
RailsRuby /opt/local/bin/ruby

VirtualHostの設定でrailsアプリケーションの位置を指定。

<VirtualHost *:80>
        ServerName test.hoge.com
        DocumentRoot /path/to/rails/public
</VirtualHost>

apacheを再起動。

> apachectl configtest
> sudo apachectl restart

無事動作しました。
mod_rails(passenger)はmogrelの3倍メモリを食う? らしいですが、どちらを使おうか。

ちなみにapacheを再起動することなく、railsアプリケーションを再読み込みしたい場合はrailsアプリのtmpディレクトリに restart.txt を置けば(または更新すれば)よいとのこと。ふむ。
Passenger users guide

カテゴリー: 未分類 タグ: , ,

railsアプリのルートURLをhttp://domain/hoge/のようにする。

2008 年 1 月 4 日