Monday, November 29, 2010

My Phusion Passenger Checklist

I spent some considerable time trying to get the "hello world" rails app (the one you get when you run rails new myapp) to run under Apache + Passenger the same way it does under rails server.

I tried both root and sub URI setup and was basically struggling with variations of the following three errors:

  • Apache would serve static content out of the document root and then send 404 for the default /rails/info/properties route (Apache
    s 404, not RoR's 404)
  • The Passenger would engage but then fail to start the rails app
  • The Passenger engages and rails app starts but the default /rails/info/properties would report a "No route" error even for local request (telnet from within the SSH)

Without going into very much details (drop me a line if you're interested and I will elaborate) here are the things that you should check:

  • Permissions for the folder the document root is pointing out. It has got to be accessible and executable by the Apache's user
  • Have the mod_rewrite loaded. The default Apache installation that you get with "sudo apt-get install apache2" doesn't have it and the Passenger's doc (at least the pieces I skimmed through) doesn't explicitly tells you to have it on.
  • The default /rails/info/properties controller works for local requests only and only in the development environment. Passenger runs your rails app in production environment by default. So make sure to have the config.consider_all_requests_local set to true and also use the RailsEnv development directive in the Virtual Host configuration
  • You don't need the in your application root. Passenger might treat your app as a Rack app and it's not. Not sure if this one helped me but I googled it up before I figured I was missing the rewrite mode so I followed the advise

Right now both built-in rails server and the kosher Apache show exactly the same result and render the well known "You're riding Ruby on Rails" including the little environment details AJAX piece.


I would have been proud if I figured it all in "no time" as the documentation suggested :)

No comments: