7

i run Apache web server on windows in order to work on some Perl CGI scripts. in production these scripts run on a linux box, and in the source code repository they all have shebangs like: #!/usr/bin/perl, but on my windows machine the shebangs would be #!c:\perl\bin\perl.exe, so i have a conflict with the source code base.

enter the Apache ScriptInterpreterSource directive.

i've been trying to make it work, based on what i can google. but so far no luck. i have:

  1. added these things to the appropriate directive AllowOverride None
    Options Indexes FollowSymLinks ExecCGI Order allow,deny Allow from all ScriptInterpreterSource Registry-Strict

  2. added: AddHandler cgi-script .cgi

  3. edited my registry and added a new String to

HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command=C:\Perl\bin\perl.exe

now, i know that CGIs work on this server as long as they have the right shebang.

but when i try to access a CGI without a shebang the apache log spits out:

No Exec CGI Verb found for files of type '.cgi'

any thoughts, insights, or even wild-ass guesses would be appreciated.

thanks.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
user46775
  • 239
  • 4
  • 8

3 Answers3

10

It sounds like the ScriptInterpreterSource line is being ignored. If it's set to Registry or Registry-Strict, it should ignore the shebang lines and use the registry only.

Also, the Apache 2.2 docs have a slightly different location for the registry key:

HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command\(Default) => C:\Perl\bin\perl.exe -wT
Powerlord
  • 87,612
  • 17
  • 125
  • 175
  • Verified this works for Apache 2.2.11 (Win32) with mod_perl 2.0.4 and perl v5.10.0 – shufler Jun 11 '09 at 23:06
  • This fixed my problem, but, I found that using the `-T` switch can cause problems with older code (for example, it causes `@INC` to not consider relative paths). – Nick Bolton Jan 10 '10 at 13:49
  • Thank you, this was driving me crazy. Works w/Win2008 Apache 2.2.22, ActivePerl 5.12.4 – andersop Mar 13 '12 at 22:58
2

This works for Python scripts as well. I did the following to fix my Apache install to ignore the shebang requirement in my scripts. Without this the shebang is required in the current version of Apache 2.4 - or at least it was in mine.

# tell apache to use registry - this requried a registry hack
# to the following: 
# [HKEY_CLASSES_ROOT\.py\Shell\ExecCGI\Command] = "c:\\python\\python.exe"
ScriptInterpreterSource Registry-Strict
0

Instead of running your perl code in separate CGI processes, consider using mod_perl (See http://perl.apache.org).

Mod_perl is a lot more efficient, as the Perl code is loaded and parsed only once and then runs directly within the Apache processes with no need to start or communicate with other processes.

haa
  • 321
  • 1
  • 5