LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions
User Name
Password
Linux - Distributions This forum is for Distribution specific questions.
Red Hat, Slackware, Debian, Novell, LFS, Mandriva, Ubuntu, Fedora - the list goes on and on... Note: An (*) indicates there is no official participation from that distribution here at LQ.

Notices

Reply
 
Search this Thread
Old 06-27-2004, 06:24 PM   #1
CartersAdvocate
Member
 
Registered: Sep 2003
Location: Columbus, OH
Distribution: Slackware 12.2
Posts: 166

Rep: Reputation: 30
Gentoo Apache/perl problem


Ok, I just installed Gentoo and emerged perl/libperl/apache/mod_perl.

I added:

ScriptAlias /cgi-bin/ /var/www/localhost/cgi-bin/

and

LoadModule perl_module extramodules/mod_perl.so

to the /etc/apache2/conf/apache2.conf file, but when I try to load a perl script in my browser, it gives me a 500 Server error and in the Apache error_log file, it says "Premature end of script headers: hello.pl" Here is my script, but I don't think it's the script that's the problem (just a hello world perl script):
Code:
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print "<HTML><BODY>";
print "Hello world!\n";
print "</BODY></HTML>";
exit;

Last edited by CartersAdvocate; 06-27-2004 at 06:28 PM.
 
Old 06-27-2004, 06:27 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
I think the script is the problem. You are sending a malformed header - try using:
print "Content-type: text/html\n\n";

Note the colon.
 
Old 06-27-2004, 06:29 PM   #3
CartersAdvocate
Member
 
Registered: Sep 2003
Location: Columbus, OH
Distribution: Slackware 12.2
Posts: 166

Original Poster
Rep: Reputation: 30
Oops, that was my typo on the post, not the script...I'm on a different computer so I can't copy/paste...I fixed it in the original post (I have the colon there on the script)
 
Old 06-27-2004, 06:40 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
Is the file executable?
 
Old 06-27-2004, 06:41 PM   #5
CartersAdvocate
Member
 
Registered: Sep 2003
Location: Columbus, OH
Distribution: Slackware 12.2
Posts: 166

Original Poster
Rep: Reputation: 30
Yeah, 755
 
Old 06-27-2004, 08:43 PM   #6
CartersAdvocate
Member
 
Registered: Sep 2003
Location: Columbus, OH
Distribution: Slackware 12.2
Posts: 166

Original Poster
Rep: Reputation: 30
Ok, after spending most of my day on this problem, I finally found out the solution. I needed to add a Location tag to my /etc/apache2/conf/apache2.conf file. There are 2 ways to do it...you could configure the cgi-bin directory, but when I did that then my non-perl CGI scripts in that directory stopped working, so here's the way that I do it (perl scripts will be in /perl instead of /cgi-bin but it works)

Code:
Alias /perl/ "/var/www/localhost/perl/"
<Location /perl>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
Options +ExecCGI
PerlOptions +ParseHeaders
</Location>

edit: I found out how to get it to work alongside cgi-bin in the same directory also. When I was first trying it, I was doing this:

Code:
Alias /cgi-bin/ "/var/www/localhost/cgi-bin/"
<Location /cgi-bin>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
Options +ExecCGI
PerlOptions +ParseHeaders
</Location>
which would cause my non-perl CGI scripts to stop working, but if you do it this way:

Code:
Alias /perl/ "/var/www/localhost/cgi-bin/"
<Location /perl>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
Options +ExecCGI
PerlOptions +ParseHeaders
</Location>
then both perl and non-perl CGI scripts will work out of the same directory (and I have no clue why, but it works, so I'm happy)

Last edited by CartersAdvocate; 06-27-2004 at 08:52 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Perl Problem.. chazzy Linux - Software 2 03-22-2005 01:10 PM
Apache & Perl problem ginda Linux - Software 8 02-18-2005 08:45 PM
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 06:37 PM
Have problem running .pl perl script in apache adrianmak Linux - Software 4 11-10-2003 10:31 AM
perl & apache problem tanmaya Linux - Software 0 04-07-2003 04:13 AM


All times are GMT -5. The time now is 03:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration