Trick 1: What the Passenger PrefPane does
The first trick to getting it working was understanding exactly what the Passenger pref pane really does. When you add a Rails app to the Passenger pref pane, it:
- Adds this to the bottom of httpd.conf
NameVirtualHost *:80ServerName _default_Include /private/etc/apache2/passenger_pane_vhosts/*.conf
- Creates a vhost file named with the address you specified in the pref pane
- Puts the following in the vhost file
Allow from all
When you set up Passenger, if you followed instructions, you made a file called other/passenger.conf. Your passenger.conf looks something like this:
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.9/ext/apache2/mod_passenger.soPassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.9PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
The trick is that this file has to be loaded before you load any of your Passenger vhosts (aka Rails apps running under Passenger). So, the load order in httpd.conf is important.
There are three relevant lines in httpd.conf. If they are not in this order, your application simply won't run.
- Include /private/etc/apache2/other/*.conf (this loads your Passenger module and all the Rails goodness your apps need)
- Include /private/etc/apache2/extra/httpd-vhosts.conf (this loads your vhosts, if you're putting them in the file named, logically, httpd-vhosts.conf. This is where I put things when I wasn't using the Passenger pref pane. Note that this is commented out by default, so if you're going to put your things there, you need to uncomment it.)
- Include /private/etc/apache2/passenger_pane_vhosts/*.conf (this is where the Passenger pref pane puts your apps)
Trick 3: Passenger Pref Pane appends
After you've set up your application in the Passenger pref pane, if you modify it, the behavior is slightly odd. For example, I might switch the app from running in Development to Production. When I do this, the pref pane adds the following text to the vhost configuration in passenger_pane_vhosts/[my app].conf:
Order allow,denyAllow from all
It doesn't replace the original entry; it adds a new entry. This means I get several directory entries over time. So I have to go back and clean up the vhosts file by hand.
None of these things are killer, but I at least found myself rather frustrated by them. Hopefully this saves someone else some time!