Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Perl to work under Apache on RedHat 7.2

Status
Not open for further replies.

Geekmomz

MIS
Feb 21, 2002
53
US
I'm having a bit of a problem that I hope someone can help me with. I'm fairly familiar with Perl, having written several scripts over the last 5 years or so, but I never had to deal with the server itself. Now my company has decided to host our own web site, and I need to deal with the server.

The server was set up and RedHat 7.2 and Apache 1.3.2 were installed by a consultant in a trade-for-services deal. He got the web server running, and PHP working, but Perl is not properly configured. This is what I'm asking for help with.

I know Perl isn't configured properly because, while I can type "which perl" and get a reasonable response (/usr/bin/perl), I try to run a simple script and I get incorrect results. When the file extension is 'pl', I am prompted to download the file. When the extension is 'cgi', I get a 403 Forbidden error. I suspect MIME type problems on the first error and failure to give permissions everywhere they're needed on the second.

Can anyone tell me either what needs to be done to get Perl working or where I can find the information I need? Thanks a lot for your help.
Marla
 
Hi,

For simple perl you are talking about basic cgi. You would need the following in your /etc/httpd/conf/httpd.conf file :

AddHandler cgi-script .cgi .pl

ScriptAlias /cgi-bin/ "/var/
<Directory &quot;/var/ AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

If you want to use files outside of the above directory you need to define a <Directory> container with at least the 'options ExecCGI' included . For example :


<Directory /usr/local/apache/htdocs/somedir>
Options ExecCGI
</Directory>


Then you can test it out with a test script :

#!/usr/bin/perl
print &quot;Content-type: text/html\n\n&quot;;
foreach $key (keys %ENV) {
print &quot;$key --> $ENV{$key}<br>&quot;;
}


For example put that in a file called /var/ (or env.pl) and then do :

# chown apache.apache env.pl
# chmod +x env.pl

And test via
Thats using perl throuugh the CGI mechanism. For speed you'd want to do it via modperl. See the following for the basics -->

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top