Setting up Perl/CGI to work with Windows Server 2003
The following things are assumed:
Also, all of my reasoning is explained after the step-by-step is done, at the bottom of the page.
Load IIS from the Administrative tools in the Control Panel by clicking Start -> Administrative Tools -> IIS Manager (or loading the Control Panel, entering the Administrative Tools folder, and double clicking IIS Manager).
Click the name of your computer then click "Web Service Extensions", on the left side of the main frame you will see a green arrow pointing to a link that says "Add a new Web service extension...", click that link.
In that window, where it asks for the extension name you can put anything, like "CGI script" and under the "Required Files" section put the following in (without the apostrophes) 'C:\Perl\bin\perl.exe "%s" %s' click OK to the notification, click "Set status to allowed" and press ok.
Now, load up a command prompt (Start->Run... type cmd) and type (without the quotes) "md c:\inetpub\cgi-bin"
Back in the IIS Manager right click Default Web Site highlight "New" in the pop-up menu and click "Virtual Directory..." in the new menu
Click next to the first dialog in the wizard, then as a the alias put "cgi-bin" and click next then as a path for the next dialog put in "c:\inetpub\cgi-bin". On the next dialog leave everything checked and check execute and click next
Click Finish to end the wizard.
Now right-click cgi-bin and click properties
Click Configuration in the lower right-hand area of the dialog and make sure .pl is there (if it isn't, add it the way you see it)
Making your scripts work
To make your scripts work the shebang line (#!/usr/bin/perl) should now be #!C:\Perl\bin\perl.exe . Any reference to any files should be changed from /home/user etc, to c:/home/user or c:\\home\\users - note the double back-slashes.
Also, renaming your .cgi scripts to .pl is highly recommended - it's what I do myself ;-)
Assuming this is all done correctly, you should now be able to run your Perl scripts successfully using Windows Server 2003, and IIS 6.0
Q: Why do you make cgi-bin in \inetpub and not in \inetpub\wwwroot even though you're going to be making a Virtual Directory there anyway?
A: The reason I go through these extra few steps are (1) To bring in a Command shell (open one of those and you immediately look smart, plus it makes things go wwaaayyy quicker) (2) I got it from the *nix world, what can I say, back when I hosted on Linux that's the way the directories were set up, so it stayed with me bottom line is, you don't need it like that, it's just the way I prefer.
Q: Why do you have a cgi-bin folder at all?
A: It is always better to keep your scripts separate from your regular files.
Q: If you know that ActivePerl 5.8.2 Build 808 and higher automagically add the service extensions, why do you still have this tutorial?
A: Many reasons. First, this tutorial isn't only for Perl, but for anything similar. Second, just in case :-)
<-- Go back to the main tutorial page
Copyright ©2002-2017 Jonathan Maltz. For trademark/copyright information, click here. About me. Main page. Contact me.