I have been trying to run a simple perl-cgi script on windows 7. This is a simple HTML form with an OK button where clicking on OK button displays some text. But clicking the OK button on the HTML page, instead of executing and displaying perl file's output, the browser starts downloading the script. I have added handler in httpd.conf
AddHandler cgi-script .pl
But this doesn't help. I added the ExecCGI option in the httpd.conf but that didn't help either.
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
Here is the perl script being used:
#!C:\Perl\bin\perl
use CGI;
print "Content-type: text/plain","\n\n";
print "<html>","\n";
print "<head>\n\t<title>Server Information Ready</title>\n</head>","\n";
print "<body>","\n";
print "<h1>Server Information</h1>","\n";
print "</body></html>","\n";
And here is the html file:
<html>
<head><title>Server Information</title></head>
<body bgcolor="#EEAA55">
<h3>Please click OK to get the server information</h3>
<hr><pre>
<form action="http://localhost/cgi-bin/ctest/pranav1a.pl" method="post">
<input type="submit" value="OK">
</form>
</hr></pre>
</body>
</html>
I have tried this on chrome, IE and Mozilla. Mozilla and chrome start the perl file download, but IE just displays some weird content on clicking the OK button. How can I make the browser display output of file execution rather than starting the script download ?
PS: I have tried to use shebang line as '#!c:/Perl/bin/perl' which doesn't seem to work either. I am able to see the perl script's output when executed from cmd prompt.
LoadModule cgi_module modules/mod_cgi.so
Add a ScriptAlias:<IfModule alias_module>ScriptAlias /cgi-bin/ "C:/BitNami/apache2/cgi-bin/"</IfModule>
ScriptAliases are essentially the same as Aliases, except that documents in the target directory are treated as applications and run by the server when requested rather than as documents sent to the client. – ScavokovichAddHandler cgi-script .pl
(likely there's already one for the .cgi extension; if not, add it also. And you may want to put your .pl in /cgi-bin instead of the sub-directory ctest. – Scavokovich