8.4. Using Windows File Extensions to Launch CGI Programs
Problem
You want to have CGI programs on Windows executed by the program
associated with the file extension. For example, you want .pl scripts to be executed by perl.exe without having to change the
scripts’ #!
line to point at the right location of perl.exe.
Solution
Add the following line to your httpd.conf file:
ScriptInterpreterSource registry
Discussion
Because Apache has its roots in the Unixish world, there are a number of things that are done the Unixish way, even on Microsoft Windows. CGI execution is one of these things, but the ScriptInterpreterSource directive allows you to have Apache behave more in the way to which Windows users are accustomed.
Usually, on Windows, a file type is indicated by the file extension. For example, a file named example.pl is associated with the Perl executable; when a user clicks on this file in the file explorer, Perl is invoked to execute this script. This association is created when you install a particular program, such as Perl or MS Word, and the association is stored in the Windows registry.
On Unixish systems, by contrast, most scripts contain the
location of their interpreter in the first line of the file, which
starts with the characters #!. This
line is often called the shebang line (short for
sharp bang, which are the shorthand names for the two
characters).
For example, a Perl program might start with the line:
#!/usr/bin/perl
The shell running the script looks in this first line ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access