mongrel_cluster -> mod_rails (Passenger 1.0.1)
http://www.moongift.jp/2008/04/passenger/
mod_rails (Passengenr)がリリースされたので、mongrel_cluster & mod_proxy_balancer から mod_rails にswitchしてみた。サーバはCentOS 5。
Debian系だとUbuntuは6.06と7.10,DebianはSarge,Etch,Lenny/Sidがテストされてる?
$ sudo gem install passenger $ sudo passenger-install-apache2-module Welcome to the Passenger Apache 2 module installer. 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を入力してenter
略 ------------------------------------------- The Apache 2 module was successfully installed. Please edit your Apache configuration file, and add these lines: LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/ext/apache2/mod_passenger.so RailsSpawnServer /usr/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/bin/passenger-spawn-server RailsRuby /usr/local/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. -------------------------------------------- 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: /usr/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/doc/Users guide.html Enjoy Passenger, a product of Phusion (www.phusion.nl) :-) http://www.modrails.com/
適宜コピってconfファイルを編集。
$ sudo vi /etc/httpd/conf.d/railsapp.conf LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/ext/apache2/mod_passenger.so RailsSpawnServer /usr/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/bin/passenger-spawn-server RailsRuby /usr/local/bin/ruby NameVirtualHost *:80 <VirtualHost *:80> ServerName www.katahirado.jp DocumentRoot /u/apps/katahirado/current/public </VirtualHost> <VirtualHost *:80> ServerName railsapp2.katahirado.jp DocumentRoot /u/apps/railsapp2/current/public </VirtualHost> <VirtualHost *:80> ServerName railsapp3.katahirado.jp DocumentRoot /u/apps/railsapp3/current/public </VirtualHost> <VirtualHost *:80> ServerName railsapp4.katahirado.jp DocumentRoot /u/apps/railsapp4/current/public </VirtualHost>
超お手軽。mongrel_cluster より楽。
計測してないけど、体感では速度も結構速いと感じた。
今まで4アプリ×2でmongrelを8つ動かしてたんだけど、topでさらっと確認してみた分には、mod_rails の方がメモリ使用量少ないっぽい。
しばらく運用してみよう。