Phusion Passenger

As of version 2.0, Phusion Passenger supports Rack (and thus Merb) through a Rack config.ru file placed at the root of an app:

# config.ru
require 'rubygems'
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

run Merb::Rack::Application.new

Check out the Passenger User Guide to get up and running with Passenger or jump right in:

Installation

$ gem install passenger
$ passenger-install-apache2-module

For Development

Passenger works well as a development server and many are using it as such. Here’s how to use it in development for a Merb app:

RackEnv development

When you point your browser to http://myfunkysite.local, Passenger will boot the Merb app by loading the config.ru file. Passenger will also kill the app after a default timeout so you’re not wasting memory.

Example Files

/etc/hosts

127.0.0.1 localhost myfunkysite.local

/etc/apache2/httpd.conf

# ...snip...

# These paths will vary for your installation. Passenger will give them to you at the end of its installation.
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-1.9.0/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-1.9.0
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

RackEnv development

# Only needed if getting 403 Forbidden errors on static assets:
<Directory "/Users/JohnDoe/apps">
  Order allow,deny
  Allow from all
</Directory>

<VirtualHost *:80>                  
  ServerName myfunkysite.local            
  DocumentRoot /Users/JohnDoe/apps/myfunkysite/public
  ErrorLog /Users/JohnDoe/apps/myfunkysite/log/error.log
</VirtualHost>

Most users put the Passenger config and vhost directives into separate files and use the Include directive to pull them into Apache, but that is left as an exercise for the reader.

Restarting the app

$ touch tmp/restart.txt

You’ll have to create the tmp dir in the root of your app if it doesn’t exist.

Drawback: No Debugging

Since Passenger runs your app headlessly (is that a word?) calls to debugger in your code no longer do anything—except freeze your app. Is anyone feeling up to investigating LiveConsole integration?

Edit Page | History | Version: