Thursday, October 11, 2007

Apache CGI Scripts on windows.

CGI scripts on apache installed on windows didn't work. It is because of the first line of the .cgi files.

Normally first line of .cgi file reads as #!/usr/bin/perl and on windows apache uses this first line to find the appropriate perl exe to run the script. This default behavior can be overridden by using ScriptInterpreterSource directive of apache.
Adding "ScriptInterpreterSource Registry-String" directive to apache httpd.conf file, we are telling apache to ignore the first line #!..... and instead look in to the registry for the perl exe to run the script.

If moving #!/usr/bin/perl to C:\Perl\bin\perl.exe [Correct perl.exe installation path.] works fine which conclude that ScriptInterpreterSource directive is not working properly.

Solution to the failure of apache .cgi scripts on windows is:

Edit httpd.conf file and add the line:
ScriptInterpreterSource Registry-String

Add the following key in the
registry.

\HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command.

Default value should be the location of your Perl executable.
[ex. C:\Perl\bin\perl.exe -T].




cheers, make world open...

2 comments:

Seb said...

The Line ist
ScriptInterpreterSource Registry-Strict
not Registry-String.

Thanks, Sebastian

Anonymous said...

Hi - I am certainly glad to find this. great job!