Hi! Thanks for visiting my blog. If you've received any value from my content would you mind supporting my new startup by downloading our browser add-on? It's called PriceBlink and makes online shopping a breeze. You can watch it in action here and download it for Chrome, Firefox, IE, or Safari by going to PriceBlink.com. Thank you and I hope you enjoy!

Configuring Ruby on Rails dispatch.cgi for Linux

May 14

I’ve been doing most of my Rails development using the built-in WEBrick server. I recently ran into a problem when deploying my application to a production environment. The production server was running Rails with Apache. Since I’m new to this type of configuration I ran into problems when trying to access the production app. Whenever I accessed any controller I received the following error message:

Rails application failed to start properly

After digging around I came to find out that my dispatch.cgi file (stored in the public directory) was configured incorrectly. Sometimes I do local development and testing on a PC and that’s where the problems began. When generating the Rails shell in Windows the dispatch.cgi file contains the following line:

#!c:/program files/ruby/bin/ruby

This won’t work on *nix so I had to update the statement to read:

#!/usr/local/bin/ruby

The paths to these binaries may vary depending on your environment, but you get the idea. I spent a couple of hours on this and hopefully my time invested will save you some hassle.

Leave a Reply