Rails and fcgi

software development

  • app is installed at www.mydomain.com
  • web root is www.mydomain.com/public (this works w/ regular cgi)
  • /public has correct permissions
  • .htaccess: rewrite rule changed to use .fcgi
  • shebang on dispatch.fcgi and dispatch.rb is set to #!/usr/bin/ruby1.8
    (also tried just ruby)
    -environment.rb : running in prod

Any ideas? o_O


I’d check out the Dreamhost Wiki article on ROR here


That’s what I was following :confused:


You didn’t say what the symptoms are – what message are you getting? I assume it’s one of those generic “application error” ones.

One thing that helped me when switching over was deleting session files. Look in /tmp for files owned by your user that begin with ruby_sess_ and then have a unique hash for the rest of the filename. Delete those, kill existing fcgi processes (in order to restart them), and try again.


I am having this issue too. I can run with regular CGI just fine, but get:

Application error (Rails)

when I switch the .htaccess rewrite to fcgi. I also have noticed that the application works if I execute ‘ruby script/server’ at the shell (but only on the def. port of 3000).


Ok. I figured out my problem. I had edited my dispatch.fcgi with emacs and I had a file called dispatch.fcgi~ in the directory as well.

I deleted the dispatch.fcgi~ and bingo worked!


I just figured out the minimal steps required to install and run typo on DreamHost. I created a step-by-step guide, so people can get typo installed and running quickly.


Have Fun.


I have the same problem. And I’ve enabled fast cgi. Followed the wiki, all of it. But here’s the other thing. I have my app in cvs, and use a shell script that
simply does a cvs export, and then moves it over to the domain
directory. I exported it using a cvs tag yesterday, and it worked
fine. I redeployed using the exact same tag a little while later, and
now I get the error. I’m guessing it has something to
do with processes running that I am unable to kill, and not configuration. Is there anything
else I can do besides run ‘killall -v dispatch.fcgi’ that will
guarrantee my processes die?


I am having a similar FCGI problem right now.

I run script/console or script/server and my application starts properly. If I switch the .htaccess to use dispatch.cgi, it works fine as well.

I’ve deleted all my ruby session files, I’ve killed all the existing dispatch.cgi processes, and this is the contents of my dispatch.fcgi file:

|require File.dirname(FILE) + “/…/config/environment”
|require ‘fcgi_handler’

When I run it from the shell I get:

Status: 500 Internal Server Error

And of course when I run from the browser I also get the same Rails failed to start properly error…

I’ve also tried adding the frao_handler extension to the dispatch.fcgi file, as mentioned in the Wiki, and this does nothing either.

The permissions on the file are 755 as recommended.

Anyone have any suggestions? My application was working properly yesterday. All I did was update my codebase from a local copy (replaced files in the app folder and in the public subfolders only - no ruby-specific files or system libraries).