Make Apache recognize Perl!
May 28, 2008 5:49 AM   Subscribe

How can I get my web server to interpret perl

I am playing around with perl for the first time in my life. I am using a fedora core 8 machine. It seems to ave all the essentials installed already (apache, php, mySQL, and perl). However, I make a file called perl.pl and it does not seem to translate correctly. Here is what is in the file:

#!/usr/bin/perl

print "Content-type: text/html \n\n"; #HTTP HEADER

# DEFINE SOME SCALAR VARIABLES
$number = "5";
$exponent = "2 ** 8";
$string = "Hello, PERL!";
$stringpart_1 = "Hello, ";
$stringpart_2 = "PERL!";
$linebreak = "
"; #HTML LINEBREAK TAG

# PRINT THEM TO THE BROWSER
print $number;
print $linebreak;
print $exponent;
print $linebreak;
print $string.$linebreak;
print $stringpart_1.$stringpart_2;



When you go the the browser, you see the following
http://[ip address]/perl/perl.pl

As you can see, you prints out exactly what I type. Am I doing anything wrong? Am I suppose to enable a perl service or change a configuration file?
posted by kaozity to Computers & Internet (7 answers total)
 
You need to tell Apache what to do with the perl scripts. See the article here for a guide.
posted by cdmwebs at 5:54 AM on May 28, 2008


Response by poster: When i follow those instructions, the browser reports back telling me there is an internal Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, volpe-ais@volpe.dot.gov and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
Apache/2.2.8 (Fedora) Server at [ip address] Port 80
posted by kaozity at 6:15 AM on May 28, 2008


The file needs to be executable. Make sure the permissions on perl.pl are set to 755.
posted by staggernation at 6:18 AM on May 28, 2008


Also read the Apache log files. While commonly cryptic, you can usually use them as a reference for google (ie, "apache perl ").

tail -f -n 0 /var/log/* /var/log/*/* is a fun starting spot.

posted by SirStan at 6:24 AM on May 28, 2008


Hello and welcome to web server administration! There's a first time for everything, so here we go:

I see you got this message:
"More information about this error may be available in the server error log."

Now, as a rule you'll find the server isn't going to go out of its way to fabricate lies and tell them to you. Sure, it'll happen from time to time, but generally speaking try to take it at its word first before you go flailing around. In this case it says you probably want to look in the error log. See how it says you might get some additional information from there? Try reading the additional information.

Getting used to this process (known overall as "troubleshooting") will keep you from being a helpless system administrator as you go about your duties. Actually reading error messages and paying attention to what they say is a very good first step.
posted by majick at 7:45 AM on May 28, 2008


You need to tell Apache how to handle CGI scripts. Rename to perl.cgi, make sure it's executable, and Google for something like apache enable cgi.

The fact that it's a Perl script is immaterial; that will be taken care of by the shebang line and the operating system.
posted by qxntpqbbbqxl at 7:54 AM on May 28, 2008


Yeah, the Apache Docs tell you how to get that working. You can also google around on "CGI apache"
posted by a robot made out of meat at 8:06 AM on May 28, 2008


« Older The 10 minute Sex and the City   |   tips for temporary kiwis Newer »
This thread is closed to new comments.