Premature end of script headers: dispatch.cgi


#1

Hi

I am running ruby 1.8.4 and rails 1.0.0 with Apache 2. I made a simple
rails application called demo and also created a controller called say
and an action called hello which is working fine using webrick. To run
it under Apache I created a symlink demo1 which is linked to the
demo/public directory. If I run it using www.example.com/demo1 then I
get the “Rails- Welcome Aboard” page. However, the problem starts when I
try to access www.example.com/demo1/say/hello. It gives, “Application
error
Rails application failed to start properly” When I do a tail -f
error_log then I get “Premature end of script headers: dispatch.cgi”.
Since I spent almost a day trying to work out the problem and visiting
several forums where most of the people advise on checking the
permission of log files and shebang in dispatch.cgi which I already
checked but now I am not sure what is wrong.

I would be really grateful if you could tell me what I might be doing
wrong.

Please let me know if you want to have a look at my dispatch.cgi or any
other file.

Thanks a lot in advance.


#2

Try to run dispatch.cgi from the command line.

Also, make sure it’s executable.


– Tom M.


#3

Hi Tom,

Thanks for the reply. I tried running it from the command line
(./dispatch.cgi) and I get a “500 internal Server Error”

Any ideas why I am getting this?

Thanks

Tom M. wrote:

Try to run dispatch.cgi from the command line.

Also, make sure it’s executable.


– Tom M.


#4

On Mar 21, 2006, at 11:42 PM, Nas wrote:

Thanks for the reply. I tried running it from the command line
(./dispatch.cgi) and I get a “500 internal Server Error”

Any ideas why I am getting this?

That’s actually a good sign(!)

In my experience, that means everything is basically OK,
and the error is generated because there is no request
on STDIN (when you run it via the command line).

  1. Is it really dispatch.cgi or is it dispatch.fcgi?
  2. This may have to do with web server config, since
    it appears (in a rather twisted fashion) that all
    else is OK.


– Tom M.


#5

Tom M. wrote:

On Mar 21, 2006, at 11:42 PM, Nas wrote:

Thanks for the reply. I tried running it from the command line
(./dispatch.cgi) and I get a “500 internal Server Error”

Any ideas why I am getting this?

That’s actually a good sign(!)

In my experience, that means everything is basically OK,
and the error is generated because there is no request
on STDIN (when you run it via the command line).

  1. Is it really dispatch.cgi or is it dispatch.fcgi?
  2. This may have to do with web server config, since
    it appears (in a rather twisted fashion) that all
    else is OK.


– Tom M.

Yes, it is dispatch.cgi, so what might be wrong with the server config?

I have copied a portion of my config file below, please let me know if
you find something wrong in there.

<VirtualHost **********:80>
ServerName :80
ServerAlias www.

UseCanonicalName Off
ServerAdmin "@.com"
DocumentRoot /var/www/vhosts/
/httpdocs
CustomLog /var/www/vhosts/
/statistics/logs/access_log
ErrorLog /var/www/vhosts/
***/statistics/logs/error_log

    ScriptAlias  /cgi-bin/ /var/www/vhosts/*******/cgi-bin/
    <IfModule mod_ssl.c>
            SSLEngine off
    </IfModule>
    <Directory /var/www/vhosts/*******/httpdocs>
    <IfModule mod_perl.c>
    <Files ~ (\.pl$)>
            SetHandler perl-script
                                                                                                   PerlHandler 

ModPerl::Registry
Options ExecCGI
allow from all
PerlSendHeader On



php_admin_flag engine on
php_admin_value open_basedir
“/var/www/vhosts//httpdocs:/tmp"


php_admin_flag engine on
php_admin_value open_basedir
"/var/www/vhosts/
/httpdocs:/tmp"


<Files ~ (.py$)>
SetHandler python-program
PythonHandler mod_python.cgihandler



<Directory /var/www/vhosts/
******/httpdocs/demo/public/>
Options ExecCGI FollowSymLinks
AddHandler cgi-script .cgi
AllowOverride all
Allow from all
Order allow,deny

<Directory /var/www/vhosts//web_users>

AddType text/plain .php .php4 .php3 .phtml
php_admin_flag engine off


AddType text/plain .php .php5 .php4 .php3 .phtml
php_admin_flag engine off


Alias “/error_docs” "/var/www/vhosts/
/error_docs”
ErrorDocument 400 /error_docs/bad_request.html
ErrorDocument 401 /error_docs/unauthorized.html
ErrorDocument 403 /error_docs/forbidden.html
ErrorDocument 404 /error_docs/not_found.html
ErrorDocument 500 /error_docs/internal_server_error.html
AddType application/x-httpd-eruby .rhtml

Thanks in advance


#6

Tom M. wrote:

I know nothing about Rail via CGI on Apache.

One thing I notice right away, however, is that
there doesn’t appear to be anything in your config
that would direct Rails URLs to dispatch.cgi…


– Tom M.

Any idea, how can I do that?


#7

I know nothing about Rail via CGI on Apache.

One thing I notice right away, however, is that
there doesn’t appear to be anything in your config
that would direct Rails URLs to dispatch.cgi…


– Tom M.


#8

Nas wrote:

Tom M. wrote:

I know nothing about Rail via CGI on Apache.

One thing I notice right away, however, is that
there doesn’t appear to be anything in your config
that would direct Rails URLs to dispatch.cgi…


– Tom M.

Any idea, how can I do that?

Now I am using fcgi and its working fine. I think thats the reason
people advise to use fast cgi.

Anyway, thanks for your replies Tom.

Nas