This tutorial explains how to run CGI scripts written in Perl with your Windows httpd server. The information presented here is a simple variation of John Cope's wonderful Win-httpd CGI-DOS solution.
Here's the problem in a nutshell: Windows httpd is a Windows 3.1 server package that comes preconfigured to run Visual Basic CGI programs and MS-DOS batch (.bat) CGI scripts. Windows httpd is not preconfigured to run Perl scripts until you make a few modifications to your environment. The background section of John's solution explains this issue in detail.
Take the following steps to make the necessary modifications to your system:
Here's those URLs again, if you're reading this off-line:
Perl 4:
Unzip the distribution ZIP file from the C:\ prompt
by typing PKUNZIP -D BPERL4X.ZIP .
This creates
the C:\PERL-4.036 and C:\PERL-4.036\LIB directories.
Rename the first directory to C:\PERL, using
the command MOVE PERL-4.036 PERL .
Perl 5:
Unzip the distribution ZIP files from the C:\ prompt
by typing PKUNZIP -D PERL5*.ZIP .
This creates
the C:\PERL-5.000 and C:\PERL-5.000\LIB directories.
Rename the first directory to C:\PERL, using
the command MOVE PERL-5.000 PERL .
SET TEMP=C:\SYSTEMP
SET COMSPEC=C:\DOS\COMMAND.COM
PERL5 users should also add the line
SET PERLLIB=C:\PERL\LIB
Be sure that you don't already have TEMP and COMSPEC defined. Also, be sure that there is a copy of COMMAND.COM in your C:\DOS directory.
Program Filename: %COMSPEC%
Window Title: perlVM
Optional Parameters: /cPERL.EXE
Start-up Directory: %TEMP%
Video Memory: Low Graphics
Memory Requirements: KB Required 640 ; KB Desired 640
EMS Memory: KB Required 0; KB Limit 1024
XMS Memory: KB Required 0; KB Limit 1024
Display Usage: Windowed
Execution: Background
Close Window on Exit: Yes (check the box)
You shouldn't need to use the Advanced features. Also, you'll want to increase the memory limits if your system has more than 8M of memory and your Perl scripts demand it.
When you save this PIF, you will get a warning message. Just click on "OK".
#
ShellExec HSCRIPT.PIF
#
ShellExecOption /cPERL.EXE
#
ShellInitCmd $serverroot = 'c:/httpd';
#
ShellEnvFmt $ENV{'%s'} = '%s ';
#
# The space after the %s is required.
#
ShellScriptTempl @ARGV = '~a'; require 'cgi-dos.pl';
#
Of course, if your server root is on a drive or directory other
than C:\HTTPD , put in the correct location, replacing backslashes
with front slashes.
That should do it. Be sure to put your Perl scripts in the C:\HTTPD\CGI-DOS directory and reference them with http://your.server.name/cgi-dos/your-program.pl .
If you have any problems with this procedure, please let us know and we'll try to find the problem and post updated instructions here if necessary.