Merb and Phusion Passenger
October 14th, 2008
I posted some of this information before, but it was more geared towards the Ruby Enterprise Edition and not about Phusion Passenger
I installed Ruby Enterprise in the /opt/ruby-enterprise-1.8.6-20080810/ directory which I linked to /opt/ruby-enterprise. The installation was easy and painless, the only thing you have to remember is that you'll have a new sparsely populated GEM directory, so you might want to go ahead and /opt/ruby-enterprise/bin/gem install <insert your favorite gems here>
I was using Apache and Mongrel to serve my Rails instances, but to really benefit from Enterprise Edition, I needed to switch to Phusion Passenger (aka mod_rails). This too was very easy, the only trouble I had was I had to tell the installer where my Apache 2 header files were export APXS2=/opt/apache2/bin/apxs did the trick.
Then you need to add the passenger_module from your Apache httpd.conf file with:
LoadModule passenger_module /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.0.3
PassengerRuby /opt/ruby-enterprise/bin/ruby
Almost done, I just had to take the bits about routing to the mongrel cluster out and I was running my Rails instances with mod_rails
For my Merb app I had to add a config.ru file in the root directory with the following information
1 2 3 4 5 6 7 8 9 10 |
Gem.path.unshift("/opt/ruby-enterprise/lib/ruby/gems/1.8") require 'rubygems' Gem.clear_paths require 'merb-core' Merb::Config.setup(:merb_root => ".", :environment => ENV['RACK_ENV']) Merb.environment = Merb::Config[:environment] Merb.root = Merb::Config[:merb_root] Merb::BootLoader.run |
Notice the bit about adding the correct GEM path for Ruby Enterprise Edition then clearing it out after loading rubygems, I'm not exactly sure why that is required, but it took me a while to figure it out
So that's it now I have multiple Rails apps and one Merb app running on a Slicehost VPS using mod_rails. To be honest though I have not seen a big reduction in memory but the configuration is much easier.



Leave a Reply