2009/03/18

Passenger(mod_rails)を試す

Apache上でRuby on Railsアプリケーションを動かす/Passenger(mod_rails for Apache)の利用を参考にPassengerをCentOS5にインストールしてみた。

sudo gem install passenger

% sudo passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v2.1.2.

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:

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
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 /usr/local/bin/rake
* Apache 2... found at /usr/sbin/httpd
* Apache 2 development headers... not found
* fastthread... found
* Apache Portable Runtime (APR) development headers... not found
* Apache Portable Runtime Utility (APU) development headers... not found

Apacheのヘッダ関連のパッケージがインストールされていないので、httpd-develをインストール。

% sudo yum install httpd-devel

Installed: httpd-devel.i386 0:2.2.3-11.el5_2.centos.4
Dependency Installed: apr-devel.i386 0:1.2.7-11 apr-util-devel.i386 0:1.2.7-7.el5 db4-devel.i386 0:4.3.29-9.fc6 expat-devel.i386 0:1.95.8-8.2.1
Complete!

今度は passenger-install-apache2-module で not found が出なくなった。

/etc/httpd/conf/httpf.conf に以下の3行を追加。

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

以下の一行も追加すると、development環境でRailsアプリを実行できる。

RailsEnv development

以下のようにVirtualHostの設定を行うと/somewhereにあるRailsアプリを実行できる。


ServerName www.yourhost.com
DocumentRoot /somewhere/public # <-- be sure to point to 'public'!

0 件のコメント: