Problem with Apache Web Server

Mike Cantrell yomahz@devnull.org
Thu, 13 Apr 2000 20:01:53 -0700


Hrrrmmm... it looks like your script is printing out the error before the content-type which is causing apache
to croak. Apache expects the first line to be Content-Type: text/html  followed by 2 new lines (\n\n).

Try putting this at the start of your perl script:

print "Content-Type: text/html\n\n";

This probably won't keep the script from failing but it may let it report the whole error in the error log...
the bad header error only records the first few bytes...

Regards,
Mike Cantrell



Rick Rosinski wrote:

> Here is the error message from error_log.
>
> [Sun Apr  9 16:29:15 2000] [error] [client 127.0.0.1] malformed
> header from script. Bad header=An error occurred while perfor: /data/webmaster/homesite/cgi-bin/contents.cgi
>
> I have already tried the full path name (instead of ../), and I have tried the
> permissions (chmod 666 contents.list).  Those didn't work out.
>
> Normally, the contents.list is read (so, I would use open
> "</data.files/contents.cgi).  I gave the ">>/data.files/contents.list" because
> I want to be able to write new stuff to the file (such as Add A Link on my
> hosted site).
>
> I don't understand the "bad header", especially if this script works on the
> virtual hosting service, which also runs on Apache.
>
> And, I did trie the open ... || die ...;  It just generates the error message
> with the quotation after die, and tells which line in the script caused the
> error.
>
> Any ideas?
>
> On Sun, 09 Apr 2000, you wrote:
> > One other thing, if it is the open function that is causing your request to fail,
> > try this:
> >
> > open(FILE,  ">>../data.files/contents.list")  || die "Can't open file handle: $!";
> >
> > The  || die ("reason") will cause standard error to be written and if you have
> > httpd.conf setup correctly, this should write to the error log along with the reason
> > why it failed, and the line number of the script that caused the failure.
> >
> > Hope it helps,
> > Mike Cantrell
> >
> > >
> > > Rick Rosinski wrote:
> > >
> > > > I am running a stand-alone web server on my Slackware box.
> > > > I use it to set up my web site before uploading it to a virtual host.
> > > > The problem that I have is with the perl script that generates the table of
> > > > contents for the left frame of my web site (http://www.rickrosinski.com)
> > > > The copy on the virtual host works fine, but the same script generates an
> > > > internal server error, and the table of contents is not generated.  This was
> > > > not a problem on the SuSE system that I once had set up on the same box.
> > > > I had narrowed the problem down to this:  It seems that when any "open (FILE,
> > > > ">>../data.files/contents.list") is encountered, it crashes with the Internal
> > > > Server Error.  I am running as root, all file permissions seem correct, and the
> > > > same scripts work fine on the virtual server.  Also, all scripts that don't
> > > > involve file access work fine on the local server.  I am using Apache 1.3.12.
> > > > Also, when I just run "perl /cgi-bin/contents.cgi", the correct HTML is
> > > > generated, including the table of contents from "../data.files/contents.list".
> > > >
> > > > So, I think that there is a problem with Apache and file access.  Perl works
> > > > fine, and the virtual host works fine.  What could be wrong with Apache?
> > > >
> > > > --
> > > > Rick Rosinski
> > > > http://www.rickrosinski.com
> > > > rick@rickrosinski.com
> > > >
> > > > _______________________________________________
>