I keep getting a Recognition failed for “/dispatch.fcgi” error. I
search for a solution and the closest I came to finding one was
someone saying “look at the Rewrite in .htaccess and you’ll be able
to figure it out.” Well, I can’t! If anyone could help, I would
appreciate it.
Thanks!
Floyd
What does your .htaccess look like? Maybe we can start there. Also,
I assume you’re running Apache. Provide some more details.
Michael
Michael,
You assume correctly. I am running Apache 1.3 on Mac OS X 10.4
Server. Here’s my .htaccess file. It’s the default on that ruby
creates.
General Apache options
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
If you don’t want Rails to look in certain directories,
use the following rewrite rules so that Apache won’t rewrite
certain requests
Example:
RewriteCond %{REQUEST_URI} ^/notrails.*
RewriteRule .* - [L]
Redirect all requests not available on the filesystem to Rails
By default the cgi dispatcher is used which is very slow
For better performance replace the dispatcher with the fastcgi one
Example:
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
RewriteEngine On
If your Rails application is accessed via an Alias directive,
then you MUST also set the RewriteBase in this htaccess file.
Example:
Alias /myrailsapp /path/to/myrailsapp/public
RewriteBase /myrailsapp
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
In case Rails experiences terminal errors
Instead of displaying this message you can supply a file here which
will be rendered instead
Example:
ErrorDocument 500 /500.html
ErrorDocument 500 “
Application error
Rails application failed
to start properly”
Thanks!
Floyd
Any progress on this? Are you running fastcgi or fcgid, or are you
just trying to use mod_ruby? Generally I’ll get the 500 error when
the permissions aren’t right on the log and tmp directories. The web
server needs to be able to write into both of these.
Michael
Change this line:
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
to
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
Everyone forgets that one. You also don’t need both handlers at the
top. Just the fcgi one.
Michael
The tmp and log directories are world writable. I looked in the
development.log file and saw this towards the end:
ActionController::RoutingError (Recognition failed for “/
dispatch.fcgi”):
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/
action_controller/routing.rb:488:in recognition_failed' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/ action_controller/routing.rb:478:in
recognize!’
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:
38:in dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/ fcgi_handler.rb:150:in
process_request’
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/
fcgi_handler.rb:54:in process!' /usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:600:in
each_cgi’
/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:597:in each_cgi' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/ fcgi_handler.rb:53:in
process!’
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/
fcgi_handler.rb:23:in `process!’
/Users/macmage/Sites/maccrafters/guestbook/public/dispatch.fcgi:24
In the fastcgi.log file, I saw this:
[13/May/2006:20:07:58 :: 28217] asked to terminate immediately
[13/May/2006:20:07:58 :: 28217] terminated by explicit exit
Did you happen to notice anything amiss in my .htaccess file I
provided in my previous email?
Thanks for the help,
Floyd
Thanks, but I had already changed the rewrite rule and still no go.
I took out the additional handler and it still doesn’t work. I’m
sure it’s something simple I’m missing. I’m just not sure what!
Thanks!
Floyd
I got it figured out. It was the RewriteBase line. When I
uncommented it and changed the path, everything worked fine.
Floyd