How-To Geek

How to Install Perl on IIS 6 for Windows Server 2003

Perl is a very popular scripting language which is used to develop a wide variety of tools. One of it’s well know uses is web based CGI (Common Gateway Interface) applications which allow Perl scripts to be executed from a web server. With a little configuration, you can configure IIS 6 on your Windows Server 2003 system to serve Perl scripts via CGI.

Copying the Perl Binaries

Before any IIS setup can be done, the Perl binary files must be extracted to your system. Download the ActiveState Perl distribution package (get the AS zip file and not the installer) and extract them to a folder on your server (i.e. ‘C:perl’). We will map IIS to use the files located in this directory.


Configuring IIS 6 to Run Perl Scripts

Open Internet Information Services Manager to the Web Service Extensions and select the option to add a new extension.


Set the following properties:

  • Extension name: Perl CGI
  • Required files: C:perlbinperl.exe “%s” %s (assuming you extracted the files to ‘C:perl’)
  • Status set to allowed

Once finished, apply your changes.


You should see the new extension in the Web Service Extension list with the status set to allowed.


With the service extension installed, we have to create the Perl script file type mappings.

Right click on the Web Sites folder and go to the Properties dialog.


On the Home Directory tab, open the Configuration dialog.


To allow IIS to execute Perl script files (.pl), add an extension mapping with the following properties:

  • Executable: same as the “Required files” entered when creating the “Perl CGI” extension above
  • Extension: .pl
  • Verbs: GET,HEAD,POST
  • Check the box for script engine

Once finished apply your changes.


Additionally, if Perl scripts will be deployed as CGI files (.cgi), an extension mapping will need to be configured for this file type as well:

  • Executable: same as the “Required files” entered when creating the “Perl CGI” extension above
  • Extension: .cgi
  • Verbs: GET,HEAD,POST
  • Check the box for script engine

Once finished apply your changes.


After making the required configuration changes to IIS, run the “iisreset” command from the command prompt to ensure the changes are pushed through and active.


At this point, IIS 6 should be able to successfully serve Perl scripts.

Testing Perl

At this point, your server is ready to go, but just to be sure we can confirm your Perl setup through IIS pretty easily. Create a couple of text files in the directory ‘C:Inetpubwwwroot’ named ‘’ and ‘test.cgi’ both containing the following:


use strict;
use CGI;
my $test = new CGI;

print $test->header(“text/html”),$test->start_html(“Perl Test”);
print $test->h1(“Perl is working!”);
print $test->end_html;

Finally, browse to the addresses: ‘http://localhost/’ and ‘http://localhost/test.cgi’ on your server and you should see a message stating that Perl is working. If the page loads successfully, Perl is now up and running on your machine.



Once you have Perl up and running on your Windows system, you can deploy or develop your own Perl CGI applications.


Download ActivePerl from ActiveState (AS Zip Package)

Jason Faulkner is a developer and IT professional who never has a hot cup of coffee far away. Interact with him on Google+

  • Published 08/2/10

Comments (10)

  1. Robert

    It didn’t work I got a Forbidden 404 Error

  2. R

    Worked, nice and simple.

  3. Devin

    Didn’t work for me. I get incomplete headers error when I try running your test scripts.

    CGI Error
    The specified CGI application misbehaved by not returning a complete set of HTTP headers.

  4. eidylon

    I was getting the 404 error. I finally got it by pointing both the .pl mapping AND the web-service-extension to %PERL%perlis.dll, NOT to perl.exe. Then it worked fully as expected! :)

  5. bobl

    Same as Devin … “CGI error” … which is an improvement (?) since previously it would just go off into the ether “… waiting for …” and then finally time out. Maybe I’ll try the perlis.dll per eidylon ???

  6. Jason Faulkner

    I just did a walk-through on a clean system and it worked. Regarding the 404 error, just for the sake of testing, try this:

    1. Go to the Web Service Extensions section of IIS
    2. Enable All Unknown CGI Extensions
    3. Enable All Unknown ISAPI Extensions
    4. Restart IIS
    5. Try again

    If this works, then there is something wrong with the Application Extension that was set up.

  7. bobl

    After digging around some, there REALLY WAS a cgi error in my original script.This works as advertised. BTW, I had used the installer for Perl, rather than installing from the zip file, as recommended.

  8. Rich Magowan

    What was the error in the script? I’m getting the CGI error. I am using c:\perl\bin\perl.exe.
    PS, I know nothing about perl, need it to support a new site I’m woking on. Will learn

  9. jeff

    In the sample code, make sure the code reads:

    (1) #!C:\perl\bin\perl.exe <–slashes
    (2) Replace all double-quotes with ***true*** double-quotes

    As a test, run the script from the command line. If it doesn't work there, don't expect IIS to do any better.

  10. Chris

    Jeff hit the nail on the head.

    Make sure they are double-quotes and not speech quotes. I copied and pasted the above code and it chucked it into notepad on the server as speech-quotes.

    Also had to change the start of the script and add in the \ between \perl\bin\perl.exe and finally got it working.

    A happy rookie scripter!

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!