PDA

View Full Version : Linux Apache



4play
02-19-2004, 12:05 AM
im trying to setup apache so i can use it to test cgi scripts in perl locally.

apache keeps showing me the scripts rather then executing them


#!/usr/bin/perl

print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Print Environment</title></head>
<body>
EndOfHTML

foreach $key (sort(keys %ENV)) {
   print "$key = $ENV{$key}<br>\n";
}

print "</body></html>";

that should work properly especially after i chmod 755. im guessing i have not setup apache properly and yes perl is installed and working ;)

shn
02-19-2004, 03:52 AM
pitty...............I was hoping some other linux user would help you. Guess we dont have many anymore <_<

You need to check your httpd.conf file. Apache is suppose to run the scripts right out the box provided you have the path to your perl interpreter in the httpd conf file. It actually looks for the default path of /usr/bin/perl anyway when the script is fired up. Looks like you have the path right but is it right in your httpd conf file?

Also check and see your not trying to run the script "outside" of your cgi directory. You need to tell apache to execute the file in the same pace you have the script ......usually that would be your cgi-bin directory if you put it there . B)

I think hax0r knows a thing or two about perl, cgi, etc, not sure :huh:

h1
02-19-2004, 05:24 AM
You might have more success by using ScriptAlias in your httpd.conf file instead of a module, but this poses a security risk.

4play
02-19-2004, 08:10 AM
i remember i was following a guide to get cgi working and i have added something to scriptalias already. also all my cgi files are placed inside the cgi-bin.

better check my httpd.conf file again.

cselik
02-29-2004, 08:20 PM
&#60;IfModule mod_userdir.c&#62;
&nbsp; &nbsp;UserDir public_html
&#60;/IfModule&#62;

&#60;Directory /home/*/public_html&#62;
&nbsp; &nbsp;AllowOverride none
&nbsp; &nbsp;Options MultiViews Indexes SymLinksIfOwnerMatch Includes ExecCgi
&nbsp; &nbsp;#Options All
&nbsp; &nbsp;#PerlSendHeader On
&nbsp; &nbsp;Addhandler cgi-script .cgi
...


i know i have been looking for the solution for 2 weeks.
i came up with the config above.
hope it helps.

4play
03-03-2004, 05:42 PM
cheers cselik that worked a treat. :)