- ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/"
You can add it yourself manually, but since the default httpd.conf file that is supplied by Apache already comes with that line commented out, the simplest thing would be to search for that string in your existing file, and remove the preceding comment character, that is, remove the "#". If you want the .pl extension recognised as a CGI script as well, simply append the extension to the list, as follows:
- AddHandler cgi-script .cgi .pl
Next, search for the line that says " in the file. It should look something like this:
- <Directory />
- Options FollowSymLinks
- AllowOverride None
- </Directory>
Add "+ExecCGI" to the options list. The line now looks like this:
- Options FollowSymLinks +ExecCGI
3. Making a CGI Script Your Default Page If you want to make your CGI script execute as the default page for a directory, you have to add another line to the Apache configuration file (httpd.conf). Simply search for the line in the file that begins with a "DirectoryIndex" and add "index.cgi" to the list of files on that line. For example, if the line used to be:
- DirectoryIndex index.html
change it to
- DirectoryIndex index.cgi index.html
Modifying Your CGI Script
As it stands, if your CGI script is a Windows executable, it would be executed by Apache correctly. However, if it's a script that relies on an interpreter such as Perl or Python, you will have to modify the first line of the script.
Your Perl script will typically contain an initial line of
- #!/usr/bin/perl
or some such thing. This tells a Unix-based kernel to look for an interpreter at the path "/usr/bin/perl" and invoke it to interpret the instructions in the file.
Since the script now runs on Windows, and it is unlikely that you installed your Perl interpreter in a /usr/bin directory, you will need to change that first line to point to the real location of your Perl interpreter.
For example, on my Windows box, I have to change the first line of my Perl scripts to:
- #!c:/program files/perl/bin/perl.exe