暇な休日なのでpassengerとredmineで遊ぶことにした
まずMacPortsでApache2をインスコ
$ sudo port install apache2
libtool: compile: unable to infer tagged configuration libtool: compile: specify a tag with `--tag' make[3]: *** [unixd.lo] Error 1 make[2]: *** [all-recursive] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all-recursive] Error 1
libtool(1.5.24_2)が何か文句言ってるようだ。最新版(1.5.26_0)に上げてから再度installすると成功。やけくそでportsのパッケージを全部最新版にしてしまった。もしかしたらaprとかapr-utilのバージョンも関係してるかもしれない。
起動
$ sudo /opt/local/apache2/bin/apachectl start
自動起動の設定
$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
次はmod_railsことpassenger
$ sudo gem install passenger
passenger 1.0.5がinstallされた。次にpassenger_moduleの作成
$ sudo passenger-install-apache2-module
Checking for required software... * GNU C++ compiler... found at /usr/bin/g++ * Ruby development headers... found * OpenSSL support for Ruby... found * RubyGems... found * Rake... found at /opt/local/bin/rake * Apache 2... found at /usr/sbin/httpd * Apache 2 development headers... found at /usr/sbin/apxs * Apache Portable Runtime (APR) development headers... found at /Developer/SDKs/MacOSX10.5.sdk/usr/bin/apr-1-config * fastthread... found --------------------------------------------
おっと、OSXプリインストールのApache2に対してモジュールが作られてしまった。複数のApacheがある場合は、環境変数APXSとPATHを指定してから実行するようだ。
$ export APXS2=/opt/local/apache2/bin/apxs $ export PATH=/opt/local/apache2/bin:$PATH $ sudo passenger-install-apache2-module
Checking for required software... * GNU C++ compiler... found at /usr/bin/g++ * Ruby development headers... found * OpenSSL support for Ruby... found * RubyGems... found * Rake... found at /opt/local/bin/rake * Apache 2... found at /opt/local/apache2/bin/httpd * Apache 2 development headers... found at /opt/local/apache2/bin/apxs * Apache Portable Runtime (APR) development headers... found at /opt/local/bin/apr-1-config * fastthread... found --------------------------------------------
今度はばっちりですよ。/opt/local/apache2/conf/httpd.conf に以下のを貼り付け。
LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-1.0.5/ext/apache2/mod_passenger.so RailsSpawnServer /opt/local/lib/ruby/gems/1.8/gems/passenger-1.0.5/bin/passenger-spawn-server RailsRuby /opt/local/bin/ruby RailsBaseURI /redmine
あと80番と8080番は使ってるので10080番ポートを使うように設定した。railsアプリをドキュメントルートにデプロイしない場合は、RailsBaseURIを設定し、そこをrailsアプリのpublicディレクトリのシンボリックリンクにする。どこからともなく落としてきた Redmine(設定済み)をhtdoc以下の redmine にデプロイ
$ cd /opt/local/apache2/htdoc/ $ sudo ln -s /var/www/redmine-0.7.1/public/ redmine
http://localhost:10080/redmine/
これで動きました。