ActivePerl & IIS 7.5

Posted by crex on 2011-01-14 04:13

I am trying to run ActivePerl 5.12.2 (x64, MSI install) on a Windows Server 2008 R2 (IIS 7.5). I intend to use it for AWStats 7.0.

The Hello World (/perl64/eg/ example works, but I can't get Perl to run under IIS. I have added Handler Mapping (*.pl, CgiModule and C:\Perl64\bin\perl.exe “%s” %s) , but I'm not really sure what settings is the proper one i.e. maybe ISAPI or some of the DLL:s!? The info on Internet all seems to concern older versions of IIS and/or Perl. I have seen recommendations to allow 32-bit applications in AppPool so that is enabled.

Does it matter if I add the mapping as "Add Script Map..." or "Add Module Mapping"? I have tried both, and also as a IsapiModule.

When I try to run a script on server I get "HTTP Error 404.17 - Not Found. The requested content appears to be script and will not be served by the static file handler."

crex | Wed, 2011-01-19 05:44

Have also tried Handler Mappings with Module Mapping IsapiModule and Perl512.dll or PerlSE.dll with same 404.17 error. No PerlIS.dll or PerlEX.dll found.

chorny | Wed, 2011-01-26 09:08

Read and

P.S. Is requirement for IIS mandatory? Using Apache may be easier.

P.P.S. Or you can make awstats create static pages periodically.

ActiveState Staff
Thu, 2011-01-27 16:44

PerlEx and PerlIS are still 32-bit only. The dlls don't exist in a 64-bit ActivePerl.

References to using the 32-bit Application pool assume that you are using a 32-bit ActivePerl, and in that case the two dlls will be present.

crex | Wed, 2011-02-09 04:27

Thanks for the answers. From the above I conclude that ActivePerl x64 doesn't work with IIS7.5. I'll try the 32-bit version of ActivePerl.

jmrathbun | Sun, 2011-05-08 13:16

After an epic struggle characterized by a serious dearth of competent help, I found the answer in the Perl documentation (which could use a good index!). What worked for me in Windows 7 with IIS 7.5 was to
1. Run cmd.exe with administrative privileges (you have to enter cmd in the START - Search box; right click on cmd.exe at the top of the pop-up and select Run as Administrator)
2. At the command prompt, type CD \perl64 (if you used the default install location for perl) and press enter (you will get a new command prompt C:\Perl64>)
3. Now type ap-iis-config add all (and press enter)
4. Create a very simple script with a name like that should return some HTML code and test it at the command prompt; then copy it to c:\inetpub\wwwroot\. Sample: print "Content-type: text/plain\n\n"; print "SUCCESS!\n";
5. Make sure permissions are set to make your script readable and executable.
6. Open your browser and navigate to http://localhost/

crex | Mon, 2011-05-16 00:53

Thanx jmrathbun. I get an error message when running "ap-iis-config add all". I see others also have got this error, but I haven't found a solution. Maybe this error doesn't matter. AWStats seems to work, though ...

C:\Perl64>ap-iis-config add all
Use of uninitialized value $path in -f at C:\Perl64\bin/ap-iis-config line 357.
Use of uninitialized value $path in -f at C:\Perl64\bin/ap-iis-config line 357.
Use of uninitialized value $path in -f at C:\Perl64\bin/ap-iis-config line 357.
Use of uninitialized value $path in -f at C:\Perl64\bin/ap-iis-config line 357.

jmrathbun | Mon, 2011-05-16 02:13

I saw the same error but haven't looked into it since IIS seems to work fine for me now.

dougl7573 | Wed, 2011-06-29 10:16

The perl test scripts work, but when I put in the ap-iis-config add all at the >C:\Perl64...the CMD screen just says: ap-iis-config is not recognized as an internal or external command, operable program or batch file. CMD doesn't think this ciommand exists or has!

jmrathbun | Wed, 2011-06-29 12:13

You may need to use the full path. On my computer, that is c:\Perl64\bin\ap-iis-config.bat

I also found the following in c:\inetpub\wwwroot\web.config:

<?xml version="1.0" encoding="UTF-8"?>
                <add name="Perl CGI" path="*.cgi" verb="GET,HEAD,POST" modules="CgiModule" scriptProcessor="C:\Perl64\bin\perl.exe &quot;%s&quot; %s" resourceType="File" requireAccess="Script" />

I don't know if that file is the whole answer but it won't hurt to try.

dougl7573 | Wed, 2011-06-29 13:06

Thanks - I'll give that atry. I did finally get around some of it by tell control panel to add cgi to IIS, which hadn't been done, and now I'm wading through editing the web.config file so it will alow me to call one perl scripted screen from another. What an increditble pain.

samsilver1 | Thu, 2012-05-24 23:39

iis 7.5 generates this xml code
SaticFile is part of the Handler Mappings in IIS 7.5 and
the StaticFile in the Handler Mappings must be there. I
tried modifing StaticFile and the Perl cgi script will not run.
I was not able to reset StaticFile and had to uninstall IIS and
reinstall it. cgi-bin is a virtual directory I created to run Perl
as a cgi script using the localhost webserver.

<?xml version="1.0" encoding="UTF-8"?>

dougl7573 | Wed, 2011-06-29 13:46

Whenever I try to have one perl screen script call another after the main script, I get this message:

This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".

I have been all over the place trying to find out what code to put into the web.config file to get around this, but I've gotten nowhere. What are we mere mortals supposed to do? This all worked in IIS6 but with IIS 7.5 it's a never ending disaster !

jmrathbun | Wed, 2011-06-29 18:09

This looks like a new topic. You might get more help that way.

dougl7573 | Thu, 2011-06-30 08:20

I thought about that, but it really appears to be one of the last steps in getting Perl to work in IIS 7.5, so shouldn't it be here?

marcelv | Thu, 2011-06-30 11:47


I have some additional problems with running my scripts under IIS7.5.
Simple scripts that do not include (require) any perl modules or own .pl files run fine when using ap-iis-config to configure the .pl extension to run Perl.exe

However, as soon as I "require" or "use" any file or module, I get an "HTTP Error 502.2 - Bad Gateway The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "Can't locate in @INC (@INC contains: D:/Programming/Perl64/site/lib D:/Programming/Perl64/lib . ../../cgi-bin ../../cgi-bin/lib) at .pl line 23.".

However, when I run this script from the Windows Command Prompt, the script runs fine and prints the HTTP header and HTML document correctly to the stdout.

What can be the problem?

Marcel Versteeg

dougl7573 | Thu, 2011-07-21 12:00

I had the same probelms, but I found that under Windows 7 64 and IIS 7.5, I have to use the entire path, as follows:

require "c:/GSACT/GSACT System/includes/";

Under Windows XP and IIS 6.0, I used to be able to get away with:

require '../includes/';

Does anyone know why?

dougl7573 | Wed, 2011-07-27 13:47

Under Windows 7 64 and IIS 7.5, I have to use the entire path, as follows:

require "c:/GSACT/GSACT System/includes/";

Under Windows XP and IIS 6.0, I used to be able to get away with:

require '../includes/';

Does anyone know why? Do Relative Paths work in this environment? If not, what should I use?


marcelv | Fri, 2011-07-29 23:41

Hi all,

I had hoped that someone was able to use the relative paths in the @INC variable to load modules. It seems it is an unsolvable problem?

What I do now, to make sure all my scripts work on the different servers, is to use the $0 variable (which holds the script's entire path) and use that to put absolute paths in the @INC variable so that I can include all required modules and script files on all servers without changing the code moving from one to another server.

I do it like this:

# Add the required directories to the include path
my $basedir = $0;
$basedir =~ s/\\/\//g;
$basedir =~ s/\/\Z//;
push(@INC, "$basedir/lib");
push(@INC, "$basedir/private");

sheffters | Fri, 2012-03-09 04:58

I use

our $directory;
  use Cwd;     
  $directory = cwd . '/modules/';
use lib $directory;

to load up modules.

Also, the problem I had (which brought me here in the first place!) to solve getting perl running in the first place was that IIS7.5 didnt install all the required IIS features by default. Once I'd told it to install 'application development features' it went happy as the CGI / ISAPI stuff was then loaded.



samsilver1 | Thu, 2012-05-24 22:54

Windows 7 Premium Home Edition IIS 7.5

I am still using Perl32 and I am not sure if I will be able to use
PerlScript in the asp pages. However, http://localhost/cgi-bin/ is a
success with Perl32.

IIS Manager: Handler Mappings: request path: *.pl Executable: C:\Perl\bin\perl5.14.2.exe "%s" % Enabled

IIS Manager: ISAPI and CGI Restrictions: Restriction: Allowed ISAPI or CGI Path: C:\Perl\bin\perl5.14.2.exe "%s" %s

PerlScript Engine for PerlScript in asp pages
ISAPI or CGI Path: C:\Perl\bin\PerlSE.dll Restriction: Allowed

The win32-bit installer added this when I did a complete installation and
selected all of the options.