• ARTICLES
SEARCH

How-To Geek

How to Install Perl on IIS 7 for Windows Server 2008

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 7 on your Windows Server 2008 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.

image

Configuring IIS 7 to Run Perl Scripts

Open Internet Information Services Manager and open the Handler Mappings interface. image_thumb22

Click on the action, “Add Script Map”.

image

To allow IIS to execute Perl script files (.pl), configure the new script mapping with the following settings:

  • Request path: *.pl
  • Executable: C:perlbinperl.exe “%s” %s (where ‘C:perl’ is the location where you extracted the Perl binaries)
  • Name: Perl-pl

image

In the Request Restrictions dialog, set the Verbs tab to allow the following: GET,HEAD,POST.

image

Apply all changes.

When creating the new script mapping, IIS will ask you if you want to allow this script mapping to run as a CGI application. Answer ‘Yes’ to the dialog.

image

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

  • Request path: *.cgi
  • Executable: C:perlbinperl.exe “%s” %s
  • Name: Perl-cgi
  • Verbs: GET,HEAD,POST

Once finished apply your changes and select ‘Yes’ when IIS prompts you to confirm running the script mapping as an application.

image

Once you have configured IIS to run both file types, they will be listed in your Handler Mappings.

image

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.

image_thumb30

At this point, IIS 7 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 ‘test.pl’ and ‘test.cgi’ both containing the following:

#!c:perlbinperl.exe

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/test.pl’ 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.

image

Conclusion

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

Links

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/3/10

Comments (17)

  1. bob

    just want to ask if this will work also on windows 7? Thanks.

  2. bob

    Hi,

    I just manage to work it on my windows 7 using x86 version of Active Perl

    You need to add some extensions to IIS7 under Handler Mapping, click on the servers name and then handler mapping on the right and add extensions for .cgi and .pl

    I used add script mapping and made the extensions using:

    Request Path: *.cgi

    Executable: CPerl|bin|perlEx30.dll (or what ever the path is to your perlex30.dll)

    Name: Perl-cgi

    Then click OK

    Then when it asks you to allow ISAP extension i clicked yes.

    Repeat the same for .pl extension.

    i just read some instruction on other forum, hope this will help..

  3. Carlos

    I can’t find the AS zip file for Windows (only for Linux). I did search for it and I can’t find it anywhere. Could you please point me in the right direction?

  4. Rugbyball

    BTW, Will this same instructions work for Strawberry Perl? http://strawberryperl.com/
    Seems Active Perl is a commercial application and if you use it on production servers you have to buy the $1,000 Business version to use. There free version is ONLY for testing and non-production servers.

    Strawberry Perl is completely free for all to use.

  5. Rugbyball

    @Carlos
    To get the windows zip version.
    Get the link for the MSI version. In Firefox its called Copy File Location. Link will look something like below.
    http://downloads.activestate.com/ActivePerl/releases/5.12.3.1204/ActivePerl-5.12.3.1204-MSWin32-x86-294330.msi

    Now Paste into your browser and replace the .msi with .zip So looks something like:
    http://downloads.activestate.com/ActivePerl/releases/5.12.3.1204/ActivePerl-5.12.3.1204-MSWin32-x86-294330.zip

    You will now get the Zip version and not the MSI version.

  6. Natalie Dwang

    Awesome! I was stuck in this problem for hours! Now it worked very well. Thanks so much!

  7. D M

    first, thanks to Rugbyball for the tip to get the .zip version!

    second, In Win7, when I click Ok to add the Script Map, I get this error:

    “The specified module required by this handler is not in the modules list.
    If you are adding a script map handler mapping, the IsapiModule or the
    CgiModule must be in the modules list.”

    any ideas???

  8. DaleF

    I just got this to work with Win7, using Strawberry Perl. I can’t speak for the behavior of ActiveState Perl but Strawberry objected to the use of right and left quotation marks as shown in the test scripts offered in the article. Must change “ and ” to just “. So don’t make the mistake I did by simply cutting and pasting the text from the article into a text editor.

  9. Al McNicoll

    @DM – The solution is to add CGI support. Server Manager –> Roles –> Web Server (IIS) –> Role Services –> Add role service
    Then stop and restart the webserver, and away you go…

  10. Lys

    Thank you! Wasted more than a couple of hours trying to figure out why I was getting a 404.2, and all the answers were right here all along.

  11. Jahaziel

    Thank you so much for your post
    greettings!!

  12. Jahaziel

    @DM

    I had the same problem and I tried the following

    In the part of Add Mapping you need to put the dll

    the path it seems like this: Executable: C:\perl\bin\perl512.dll

    the path may vary, only it’s an example

  13. Jahaziel

    im wrong

  14. Ian

    Thanks for putting an ending 8 hours of sheer IIS 7 misery! all is working well now.

  15. Ram

    How to create .pl , .cgi files in wwwroot directory.

  16. Ram

    Hi friends, This is ram, i am newer in perl script………………………

    How to load .pl files in c/:inerpub/wwwroot directory?

    Thanks in advance.

  17. TLM

    above script would not run as either .pl or .cgi file.
    tried script below and the .pl runs fine the .cgi stating bad http header. when save the .pl file it shows as pl type, when save the .cgi is shows as a text doc –should it?

    #!/usr/bin/perl
    print “Content-type: text/html\n\n”; #<– common http header
    print "Hello world!\n\n";
    print "Press the Enter key to exit.\n";
    ; #pause

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!