Using the Web Test Environment - Executing CGI scripts
(Page 2 of 4 )
Getting started with XAMPP, you’ll need to take a few things into consideration. If you intend to run CGI scripts, you’ll need to know the location of the Perl interpreter. This will be used in the shebang line of your CGI scripts. In Linux, you’re probably used to something like this:
#!/usr/bin/perl
On the default XAMPP installation it should be this:
#!/xampp/perl/bin/perl
Of course, you’ll need to make that change in every one of your CGI scripts.
The second thing you’ll need to take into consideration is file/folder permissions. In Linux you’re used to using chmod to change every file or folder to allow execution. This is not necessary in Windows XP since all files are given the right to execute by default. (And yes, this is a security risk.)
Apache should already be configured to allow CGI execution when installed with XAMPP. Let’s double check just to be sure. Open the httpd.conf file in notepad. It should be located in C:xamppapacheconf. Browse through the file until you find the section for your web root directory. It should look like this:
<Directory "C:/xampp/htdocs">
In that section, you should find an Options line that defines settings for Apache. Make sure that ExecGCI (and not NoExec) is included.
Options Indexes FollowSymLinks Includes ExecCGI
Down a little further in the file you’ll find the section that identifies the ScriptAlias. This is the folder where CGI scripts should be found. Typically, this is www.yourdomain.com/cgi-bin/ or similar.
The default installation puts this folder above your web root for security reasons. This is most likely not what you want and it probably won’t work with your current “live” site either. Just change the path in the ScriptAlias line to a folder under your web root.
ScriptAlias /cgi-bin/ "C:/xampp/htdocs/cgi-bin/"
Now go down just underneath that and change the folder path in the directory declaration.
<Directory "C:/xampp/htdocs/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
If you are not using a standard CGI file handler for your scripts, you can change that in this file as well. Scroll down a bit more and you’ll find the section for the mime type module. Locate the line that looks like this:
AddHandler cgi-script .cgi
You can add any extensions you like to have them treated as CGI script by Apache.
AddHandler cgi-script .cgi .pl
Next: PHP switching >>
More BrainDump Articles
More By Nilpo/Developer Shed Staff Writer