We've had a few people on our forums asking about running Perl on IIS 7. This led to some discussion on the team about getting it to work with FastCGI.
The team has been doing a lot of great work with the Web Platform Installer and Windows Web App Gallery that feature popular PHP applications. Since PHP runs best on IIS with FastCGI, I suppose it was logical to turn to FastCGI for Perl as well.
Sometimes, though, the right tool for the job is not the newest and flashiest thing. It turns out that this is the case for Perl. For many years, ActiveState has provided a free version of ActivePerl that runs great on IIS using ISAPI instead of FastCGI.
It's been a while since I've looked at ActivePerl, so I did some research last week to see the state of things and discovered that there are a few things you need to know in order to get it to work on IIS 7:
ActivePerl is available as an ISAPI for 32 bits only. This does not prevent it from running on a 64 bit install of Windows. It just means that any application pool that contains Perl content must be configured to run as 32 bit.
As of this writing, ActivePerl runs well on IIS 7, but its installer does not properly configure IIS 7 for running Perl scripts. After completing the ActivePerl installation, you will need to create handler mappings to associate requests for Perl scripts to the correct ISAPI based Perl interpreter.
There are at least two different ISAPI extensions with ActivePerl. You should make sure that you use PerlEx30.dll with IIS 7. If you use perlis.dll, you may find that response headers sent from your Perl script are added to your response page instead of going back to the client as headers.
Given the above information, here are the steps to get ActivePerl running on IIS 7:
1. Install ActivePerl from http://www.activestate.com/activeperl/. At this time, there is a link to version 5.10 for Windows (x86) on this page. This link downloads an MSI installer to your machine which you can run.
2. If you are running the 64 bit version of Windows 2008, ensure that your application pool is configured to run as 32 bit. Assuming that you will be using ActivePerl in the default application pool, these steps will do it:
- From the Windows 'Start' menu, pick run and type "inetmgr" (without the quotes). Click on 'OK".
- In the left hand pane of IIS Manager, open up the settings for your server. Click on "Application Pools".
- In the Application Pools page, select "DefaultAppPool".
- In the right hand pane, under "Edit Application Pool", click on "Advance Settings..."
- In the Advanced Settings dialog, ensure that "Enable 32-bit Applications" is set to "True".
3. Create a handler mapping that associates "*.pl" requests with ActiveState's perlex30.dll extension using the following steps:
4. In the left hand pane of IIS Manager, select your server. This will apply the following handler mappings on the entire server. If you would like to do this for just a specific site or application, you can open up the server and select any site or application. In the center pane, double click on the Handler Mappings icon.
5. When the Handler Mappings pane is displayed, click on the "Add Module Mapping..." item in the Actions pane on the right.
6. Fill out the Add Module Mapping dialog as follows:
- For Request Path, enter "*.pl".
- For Module, select "IsapiModule" from the dropdown list. Note that the ISAPI module is a prerequisite. If it does not show up on this list, it will need to be installed an an IIS optional component.
- For Executable, enter "c:\perl\bin\PerlEx30.dll" (without the quotes.) Note that this assumes that you've installed ActiveState Perl using its default location. If you installed it in another location, you will need to look there for perlex30.dll.
- For Name, enter "ActiveState Perl for .pl". Note that this name is just a label and does not affect functionality. It does need to be unique, though. If you are going to be associating other file extensions with ActiveState Perl, the names for those mappings will need to be different.
- You do not need to do anything with the "Request Restrictions..." button. If you wish to limit this mapping to specific HTTP verbs, etc., it can be done there.
7. Repeat the above steps for any additional file extensions you wish to be associated with Perl. On IIS 6, ActiveState Perl creates mappings for "*.pl", "*.plx" and "*.plex". Additionally, some applications are known to map "*.cgi" with Perl.
That's it. After doing this, ActiveState Perl should run on IIS 7.