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
ServerName csh.local
DocumentRoot "/Users/cpowell/projects/csh/public"
RailsEnv development
Order allow,deny
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!
Thanks for the investigation! Care to create an issue about this so I don't forget once I'm back to work?
ReplyDeleteCheers,
Eloy
Eloy, I went to reproduce this and trick #3 didn't occur for me. I'll keep poking and log a bug if I can get it to happen again. Thanks for the followup, though, and thanks for the useful piece of software!
ReplyDeleteI love bugs that fix themselves over time, and you're most certainly welcome :)
ReplyDelete