Setting up Perl for use with IIS 6.0, step-by-step


The following things are assumed:
  1. You are running Windows Server 2003
  2. IIS 6.0
  3. You installed ActiveState ActivePerl (http://www.activestate.com) to C:\Perl UPDATE: ActivePerl 5.8.2 Build 808 and higher should add the Web Service Extensions during install
  4. You are using default (unmodified) ACLs/Permissions
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




Written by