Setting up Passenger on OSX for Sinatra Development
I setup Passenger (mod_rails) on my Macbook Pro last night, with the Passenger Preference Pane. I ran into a few small issues while doing it, and hopefully I can share them, and their solutions.
The gem install - First I did the standard gem install.
sudo gem install passenger
Apache setup - Then do the passenger apache installation, which compiles the module, and has details about the exact content you need to insert into httpd.conf
sudo passenger-install-apache2-module
httpd.conf setup - The passenger-install-apache2-module dumps a few lines to the console that need to be included in httpd.conf. Edit /etc/apache2/httpd.conf (sudo vim /etc/apache2/httpd.conf). I put the inserted lines near line #117 in my httpd.conf, after the rest of the modules are defined.
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.0.3 PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Use the preference pane to setup an app - For testing purposes, I just used a rails app. I wanted to be sure Passenger was working correctly before going after Rack apps. Very quickly, I ran into an issue. This line was in /var/log/apache2/error_log
[Fri Aug 15 21:23:11 2008] [notice] child pid 48688 exit signal Abort trap (6) terminate called after throwing an instance of 'Passenger::FileSystemException' what(): Cannot stat '/Users/cschneid/Documents/Programming/Rails/BashFight/public/../config/environment.rb': Permission denied (13) [Fri Aug 15 21:38:17 2008] [error] [client 127.0.0.1] (13)Permission denied: access to / denied
The solution to the permissions - It turns out that there is another step that is only mentioned in a single mailing list post. Apache needs another entry allowing itself access to the files. This is different and distinct from the filesystem permissions, which confused me for a while while trying to diagnose this.
order allow,deny Allow from all
Not quite - filesystem permissions matter too! After finding mention of the apache user directory details, I thought I had it fixed. BUT… not quite. It turns out that Apache needs file system permissions all the way up and down the file system tree. As you can see above, I keep all my code in /Users/cschneid/Documents/Programming/…. What turned out to be the final problem I faced was that /Users/cschneid had a permissions of 700. Apache was giving up because of that. A quick chmod 755 /Users/cschneid fixed that problem. Just know that you need to check permissions on every directory in the path to your app.
The Sinatra App - Works exactly as you’d expect. Go see my various posts on deploying to a Passenger install (Another try w/ logging), (Deploying to Dreamhost) to see how to setup your config.ru file.
September 27th, 2010 at 7:07 am
also the perms have to be set for the parent directories also
eg. path is /usr/local/apps/foo
chmod 755 /usr
chmod 755 /usr/local
chmod 755 /usr/local/apps
chmod -R 755 /usr/local/app/foo
August 16th, 2011 at 2:39 pm
OMG…just spent the last 4 hours bashing my head against the wall - it was 755 needed on one of the directories to the app root…wish I could remember that - I’m sure it bit me before.