I’m getting the dreaded “Premature end of script headers:
dispatch.cgi” message on my production server. Before I list all the
things that I tried, let me mention that I already have a Rails app
working on this server (installed by somebody else).
Tried running dispatch.cgi from the command line, and I get a 404
page: Action Controller: Exception caught … NOT a 500 error, meaning
that dispatch.cgi (and the ruby path) is working correctly.
The permissions on the dispatch files are ok:
-rwxrwxr-x 1 admin psacln 479 Jun 18 19:50 dispatch.cgi
-rwxrwxr-x 1 admin psacln 861 Jun 18 19:50 dispatch.fcgi
-rwxrwxr-x 1 admin psacln 479 Jun 18 19:50 dispatch.rb
The permissions on the symbolic link in the httpdocs directory to
the capistrano folder is also ok.
I’m using apache, pen and mongrel_cluster. Pen and mongrel_cluster
are running ok. The apache config I’m not too sure about:
<Directory /var/www/vhosts/mydomain/httpdocs/robo>
Options +FollowSymLinks
dispatch.cgi has been created by admin - there is no other user on
the system (except mongrel and pen)
dispatch.cgi has the correct ruby path
What’s more puzzling is that the permissions, the files and the setup
are almost identical to the application that is working. Permissions
are exactly the same and all the dispatch files have been copied
directly from the application that is working.
I thought this was going to be an easy task - I guess not…
Thanks for the reply. If I start script/console I don’t get any
errors. I also don’t have any models to really test my code with, but
I do have a helper that prints “hello world” and that works.
This is the exact error that is displayed when you access the simple
controller action blah/foo:
Application error
Rails application failed to start properly
This is what is logged:
[Fri Jun 20 11:00:48 2008] [error] [client XX.XXX.XX.XXX] Premature
end of script headers: dispatch.cgi
This is what is in the access log:
XX.XXX.XX.XXX - - [20/Jun/2008:11:00:48 -0700] “GET /robo/foo/blah
HTTP/1.1” 500 259 “-” “Mozilla/5.0 (X11; U; Linux i686; en-US; rv:
1.8.1.6) Gecko/20071008 Ubuntu/7.10 (gutsy) Firefox/2.0.0.6”
AHAHAHAHA! THE RAGE!
There is a .htaccess HIDDEN file created in the public directory. That
file has to be removed. It cost me almost 8 hours of debugging!
I’m going CRAZY over this thing: I went back and I did a chmod 755 on
dispatch.cgi by mistake (not 775 as you specified). All of a sudden it
started working. I did a chmod 775 on dispatch.cgi and it stopped
working. I repeated this a few times and I thought it was all over -
the culprit being chmod 755. Then, I deployed a new release, and the
chmod trick stopped working. I kept rolling back and deploying new
releases a few times and the chmod sometimes does the trick, sometimes
it doesn’t!!! Why God? Why?
Anyway - on a different note, the application is started in
development mode, even though the mongrel cluster config file
specifies “release”. Also, with the other application that is
successfully working, I don’t need to chmod anything and it starts in
production mode as expected.
Tiberiu
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.