Forum: Ruby on Rails Premature end of script headers: dispatch.cgi

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nas (Guest)
on 2006-03-22 02:05
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.
Tom M. (Guest)
on 2006-03-22 02:29
(Received via mailing list)
Try to run dispatch.cgi from the command line.

Also, make sure it's executable.

--
-- Tom M.
Nas (Guest)
on 2006-03-22 09:42
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.
Tom M. (Guest)
on 2006-03-22 10:44
(Received via mailing list)
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.
Nas (Guest)
on 2006-03-22 11:26
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
        </Files>
        </IfModule>
        <IfModule sapi_apache2.c>
                php_admin_flag engine on
                php_admin_value open_basedir
"/var/www/vhosts/*****/httpdocs:/tmp"
        </IfModule>
        <IfModule mod_php5.c>
                php_admin_flag engine on
                php_admin_value open_basedir
"/var/www/vhosts/******/httpdocs:/tmp"
        </IfModule>
        <IfModule mod_python.c>
        <Files ~ (\.py$)>
                SetHandler python-program
                PythonHandler   mod_python.cgihandler
        </Files>
        </IfModule>
        </Directory>
        <Directory /var/www/vhosts/*******/httpdocs/demo/public/>
                Options ExecCGI FollowSymLinks
                AddHandler cgi-script .cgi
                AllowOverride all
                Allow from all
                Order allow,deny
        </Directory>
        <Directory /var/www/vhosts/********/web_users>
        <IfModule sapi_apache2.c>
                AddType text/plain .php .php4 .php3 .phtml
                php_admin_flag engine off
        </IfModule>
        <IfModule mod_php5.c>
                AddType text/plain .php .php5 .php4 .php3 .phtml
                php_admin_flag engine off
        </IfModule>
        </Directory>
        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
</VirtualHost>


Thanks in advance
Tom M. (Guest)
on 2006-03-22 12:18
(Received via mailing list)
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.
Nas (Guest)
on 2006-03-22 13:16
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?
Nas (Guest)
on 2006-03-23 17:36
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
This topic is locked and can not be replied to.