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' # Uncomment if your app uses bundled gems #gems_dir = File.expand_path(File.join(File.dirname(__FILE__), 'gems')) #Gem.clear_paths #$BUNDLE = true #Gem.path.unshift(gems_dir) require 'merb-core' Merb::Config.setup(:merb_root => File.expand_path(File.dirname(__FILE__)), :environment => ENV['RACK_ENV']) Merb.environment = "production" #Merb::Config[:environment] Merb.root = Merb::Config[:merb_root] Merb::BootLoader.run # Uncomment if your app is mounted at a suburi #if prefix = ::Merb::Config[:path_prefix] # use Merb::Rack::PathPrefix, prefix #end run Merb::Rack::Application.new
Here's a better config.ru if you're bundling your gems. It uses your bundled merb-core instead.
require 'rubygems' if File.join(File.dirname(__FILE__), "bin", "common.rb") require File.join(File.dirname(__FILE__), "bin", "common") end 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:
$ gem install passenger $ passenger-install-apache2-module
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.
127.0.0.1 localhost myfunkysite.local
# ...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.
$ touch tmp/restart.txt
You'll have to create the tmp dir in the root of your app if it doesn't exist.
Since Passenger runs your app headlessly calls to @debugger@ in your code no longer do anything—except freeze your app. Does anyone feel up to investigating LiveConsole integration?
For a static content controller, I found I had to delete merb.fcgi file from public/ folder, otherwise the static controller's action would route to the merb.fcgi file instead of their prospective erb view.
/public/.htaccess will route everything to /public/merb.fcgi by default, so delete the .htaccess file