# Dispatch.cgi issue

**URL:** <https://www.ruby-forum.com/t/dispatch-cgi-issue/90632>\
**Category:** Rails\
**Created:** [March 30, 2007, 2:44pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-issue/90632 "2007-03-30T14:44:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JPJPJP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@JPJPJP](https://www.ruby-forum.com/u/JPJPJP)\
**Post date:** [March 30, 2007, 2:44pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-issue/90632/1 "2007-03-30T14:44:10Z")

</div>

Hello,

I’m very new to Rails. I’ve been trying to set it up on my Linux server.  
The installation was smooth and painless. I followed the instructions on  
the Ruby on Rails website.

So I’m running Rails 1.2.3, ruby 1.8.4 and Gem 0.9.0. I created a new  
application:

rails testproject

I’m trying to use Apache instead of having to use WebBrick because my  
server already uses Apache. So, it should be using dispatch.cgi via  
.htaccess. When I visit the page in my browser, I get the standard  
“Welcome aboard” message. But when I click “About your applicationâ€™s  
environment” I get “Application error  
Rails application failed to start properly”. Digging into Apache’s error  
log, it is complaining about Premature end of script headers. So, I did  
some digging and found I should try running dispatch.cgi through the  
shell. When I do, I get this:

[root@fire public]# ./dispatch.cgi  
Status: 400 Bad Request  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:404:in  
`to_constant_name': Anonymous modules have no name to be referenced by (ArgumentError) from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:214:in`qualified\_name\_for’  
from  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active\_support/dependencies.rb:476:in  
`const_missing' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:117:in`reset\_after\_dispatch’  
from  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:51:in  
`dispatch’  
from ./dispatch.cgi:10

I’ve looked high and low and cannot find anything pointing to what the  
problem might be. I should note I did try running WebBrick, and through  
WebBrick everything works fine. So, it’s definitely an issue with  
dispatch.cgi I just don’t know what.

Thanks in advance.

JP

---

<div class="post-metadata">

**Author:** ![JPJPJP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@JPJPJP](https://www.ruby-forum.com/u/JPJPJP)\
**Post date:** [March 30, 2007, 2:50pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-issue/90632/2 "2007-03-30T14:50:28Z")

</div>

Usually when I get the premature end of header error, I’ve been able to  
load  
up script/console and it will crash with a more robust error message  
letting  
me know that I’ve forgotten some code in config/environment.rb. If  
you’re  
not getting an error with Webrick, I’m not sure. But I’d start looking  
around in config/environment.rb. It seems that any problems in that file  
never make it to a non-Apache log whereas bugs in other files are  
written to  
the appropriate RAILS\_ENV mode log file. Does that help? 😕

RSL

---

<div class="post-metadata">

**Author:** ![JPJPJP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@JPJPJP](https://www.ruby-forum.com/u/JPJPJP)\
**Post date:** [March 30, 2007, 3:12pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-issue/90632/3 "2007-03-30T15:12:31Z")

</div>

Thanks Russell.

So I did a bit more digging and have found that most people with this  
issue just abandon SCGI and head for FCGI and things just magically  
work. Lo and behold I compiled mod\_fastcgi as a DSO for Apache,  
installed ruby-fcgi, fixed .htaccess and hallelujah, different error!  
After digging into the development log, it was clear it was a permission  
error on tmp and after fixing that I get “For security purposes, this  
information is only available to local requests.”

YEY, it works!

I’m thinking I don’t even know why they bother to include SCGI since it  
doesn’t work for 9.5/10 people.

Thanks for your quick reply.

JP

Russell N. wrote:

> Usually when I get the premature end of header error, I’ve been able to  
> load  
> up script/console and it will crash with a more robust error message  
> letting  
> me know that I’ve forgotten some code in config/environment.rb. If  
> you’re  
> not getting an error with Webrick, I’m not sure. But I’d start looking  
> around in config/environment.rb. It seems that any problems in that file  
> never make it to a non-Apache log whereas bugs in other files are  
> written to  
> the appropriate RAILS\_ENV mode log file. Does that help? 😕
> 
> RSL

---

<div class="post-metadata">

**Author:** ![JPJPJP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@JPJPJP](https://www.ruby-forum.com/u/JPJPJP)\
**Post date:** [March 30, 2007, 3:22pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-issue/90632/4 "2007-03-30T15:22:33Z")

</div>

Heh. Man, I apologize for having misread your email. I thought you were  
talking about dispatch.fcgi [with an “f”]. [Stupid slow-acting coffee!]  
Glad  
you got things working though.

RSL

---

<div class="post-metadata">

**Author:** ![JPJPJP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@JPJPJP](https://www.ruby-forum.com/u/JPJPJP)\
**Post date:** [May 7, 2007, 7:17pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-issue/90632/5 "2007-05-07T19:17:40Z")

</div>

I’m experiencing the same problem with my server but since i’m still  
in the development stage, i prefer working with cgi mode which is more  
reactive to bugs. So i want to know if there is any configuration to  
write in the apache files to consider rails applications and .rb  
files …
