Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I am trying to run a CGI perl script on Apache HTTP server but looks like there is some issue with the configuration. I am able to post html content but with CGI I am getting the following error:

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

Please contact the server administrator, asfdsaf.@sdafdsl.com 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."

Here is what I see in server error logs:

127.0.0.1 - - [21/May/2011:21:29:04 +0530] "GET /cgi-bin/sample.pl HTTP/1.1" 500 543
127.0.0.1 - - [21/May/2011:21:29:05 +0530] "GET /cgi-bin/sample.pl HTTP/1.1" 500 543


Here is what I have in httpd.conf file in order to enable CGI scripts:

LoadModule cgi_module modules/mod_cgi.so

XML
<IfModule alias_module>
    ScriptAlias /cgi-bin/ "C:/httpd-2.2-x64/cgi-bin/"
</IfModule>



XML
<Directory C:/httpd-2.2-x64/cgi-bin>
    AllowOverride all
    Options +ExecCGI
    Order allow,deny
    Allow from all
</Directory>


<IfModule mime_module>
.
.
.
AddHandler cgi-script cgi pl
.
.
.
</IfModule>


and here is the cgi perl script that I am trying to run:
XML
#!C:\Perl\bin
print "Content-type: text/html\n\n";
print <<HTML;
<html>
<head>
<title>A Simple Perl CGI</title>
</head>
<body>
<h1>A Simple Perl CGI</h1>
<p>Hello World</p>
</body>
HTML
exit;


Could anyone please let me know if I am missing something?
Posted

1 solution

Does the anonymous web user (usually www on un*x servers) have Execute file permissions on the perl interpreter?
 
Share this answer
 
Comments
techcurrent 22-May-11 16:49pm    
Thanks for your response, Yvan.

How do I ensure this? I am running Apache web server on windows. I have given all permissions to Everyone for perl.exe.
Yvan Rodrigues 22-May-11 17:11pm    
That's pretty liberal but it should work.

I notice that your shebang line is '#!C:\Perl\bin'. I'm a unix guy, so excuse my ignorance, but normally this would be a full path to the executable, not the executable's path. e.g. #!C:\Perl\bin\perl.exe

Could you try this?
techcurrent 22-May-11 17:17pm    
Hi Yvan

I don't believe it was so silly, it worked. Thanks for the quick help, you saved my day!
Yvan Rodrigues 22-May-11 21:23pm    
Great! Glad I could help. Thanks for your vote.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900