[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help me



holy cow--somebody has mistaken me for an expert! hell, i've been
at this for weeks now, so let's see if i can confuse you a bit
by taking a stab...

first: subject line in your ReqForHep should intimate the nature of
your problem: "newbie trying to get perl/cgi running!" for example.
that'll let those of us who were fresh newbies last month know
that we might have a chance at solving your trouble...

second: good job detailing much of your setup. if you'd merely
asked a vague question "why won't my script work" then NOBODY would
be able to help you. good job.


ZocoN wrote:
> Please let me know how to configure Apache 1.3.3 and mod_perl 1.15
> in Redhat Linux 5.2.
> When I tryed to execute  http://localhost/cgi-bin/hey.pl  I am
> getting the following error
> "500 Internal Server Error" - internal error or misconfiguration,
> malformed header from script. Bad header=Hello:
> /home/httpd/cgi-bin/hey.pl
> premature end of script header
> /home/httpd/cgi-bin/hey.pl

cool. when *i* get header errors, it doesn't tell me what the
headers are. i don't get diddly. you're one step up there, already.

the way all this http stuff works is, the actual data is
preceeded by a couple of headers that tell the person's
web browser
	1) what kind of file it is (html, jpeg, java)
	2) how big it is
	3) what kind of server it's talking to
	& so forth
the main one being
	Content-Type: text/html
or
	Content-Type: image/gif

how does the browser know when it's finished reading headers,
and started on the meat of the document? answer: a blank line.

since the headers end at the first blank line, your perl
script should include something like this, at the very least:

	#!/path/to/your/perl
	print "Content-Type: text/html\n\n";
	# note 2 "\n" for blank line  ^^^^
	# now do your html generating-stuff, such as:
	print "<html><body bgcolor=ffcc00><h1>Snarky</html>\n";

note that there are lots of modules for perl that will take care
of the headers for you. from "man CGI"--

	use CGI;
	my $r = new CGI;
	print $r->header,
		$r->start_html(-title => "my web page"
			-BGCOLOR => "teal"),
		$r->h2("hi there"),
		$r->end_html;

also there's the apache config directive
	PerlSendHeaders on
which has to do with making perl automatically generate 
headers as needed (double-check yourself to be sure, via
"man mod_perl" or at http://localhost/doc/apache/manual).


> At present I have installed Apache 1.3.3 and mod_perl 1.15 and
> enabled perl module in apache by adding the foll to srm.conf
> ---------------------------------------------
> Alias /perl/ /home/httpd/perl/
> <Location /perl>
> SetHandler perl-script
> PerlHandler Apache::Registry
> Options +ExecCGI
> </Location>

don't forget that Apache::Registry scripts NEVER QUIT,
so you gotta be careful about using your global variables.

see "man cgi_to_mod_perl" and also the great documentation
at http://perl.apache.org/guide/


> and have added the foll to httpd.conf
> 
> LoadModule perl_module   modules/libperl.so
> AddModule mod_perl.c
> ---------------------------------------------
> 
> My Apache Directory Structure
> ServerRoot  /etc/httpd/
> Logs        /etc/httpd/logs/
> DocumentRoot /home/httpd/html/
> cgi-bin     /home/httpd/cgi-bin/
> *.so        /usr/lib/apache/
> *.h         /usr/module/apache/
> I have kept my perl file in /home/httpd/cgi-bin/ and my perl
> interpreter is
> at usr/bin/

> ---------------------------------------------
> #!/usr/bin/perl
> print "Content-type: text/html\n";
> print "Hello\n";
> ---------------------------------------------

aha!

first, make sure you have a blank line after your headers:
	print "Content-Type: text/html\n\n";
otherwise, how would the browser know where the document started
for a file such as this:
	Content-Type: text/plain
	Content-Length: 12345
	Dave Barry: patriotic political commentator or 
	subversive commie? This question is on the minds of...
hmm?

so try that, and if you still have trouble, we can try
again.

> Please let me know about how to configure apache to run perl, I am
> new to Linux,Apache and perl

wow.

you're in for a climb, but i hear the view from the top is
quite something!


> Thank u for reading
> Waiting to hear from u soon

HTH.


Reply to: