ActiveState Community

Trying to get Perl working with IIS 7.0

Posted by textor on 2007-05-25 08:27

I have IIS 7.0 on Vista Business and ActivePerl. However I can't get perl to run. The earlier posting http://support.activestate.com/forum-topic/configuring-perl-on-iis-7 was really useful in getting me to where i am. However I still have problems.

When I run a test program I get this

HTTP Error 502.2 - Bad Gateway
Description: The specified CGI application did not return a complete set of HTTP headers.
Error Code: 0x00000000
Notification: ExecuteRequestHandler
Module: CgiModule
Requested URL: http://localhost:80/cgi-bin/hello.pl
Physical Path: C:\inetpub\wwwroot\cgi-bin\hello.pl

However I can run the program from the command line

C:\Users\Bob> C:\inetpub\wwwroot\cgi-bin\hello.pl
Content-Type:text/html

Hello World!

Hello World!

In the default Web Site I have a handler set up - The executable is in C:\Perl\bin\perl.exe. The mapping screen shows this.

Perl *.pl Enabled File CgiModule Local

The file permissions for hello.pl are for the user IIS_IUSRS: Read & Execute and Read

The server log is not much help

2007-05-25 14:55:46 ::1 GET /cgi-bin/hello.pl - 80 - ::1 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.0;+SLCC1;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.04506) 502 2 0

I tried turning offf the (Norton) firewall but no change.

textor | Fri, 2007-05-25 09:44

OK I fixed my problem. I switched form Perl.exe to perlis.dll.

Now it magically works.

Bob

rjd1212 | Sat, 2007-05-26 06:52

Hi Bob,

Well, I took your advice on switching the .exe file to .dll file. Although either way, be it the .exe or .dll - I can sucessfully print out the static "Hello World" script through IIS7. Otherwise, I'm primarely having issues with a much more dynamic .pl file. In this case, the perl.dll file doesn't seem to resolve the error 502 message.

RJD

troyt | Wed, 2008-10-01 17:22

I kept running into this error when I was writing the documentation for ActivePerl config on IIS 7 (will be in the next ActivePerl release). I had forgotten to restart IIS.

For the record, here are the instructions:

To configure ActivePerl to work with IIS 7 on Windows Vista:

  1. Ensure that IIS is installed with CGI support.
  2. Open the IIS Manager
    (Control Panel | Administrative Tools | IIS Manager).
  3. Select the scope of the mapping in the
    Connections tree on the left. For example, if you
    want to use .pl scripts in only one website, selet that site under Web Sites.
  4. Double-click Handler Mappings.
  5. In the right pane, click Add Script Map.
  6. Configure the following in the Add Script Map dialog box:
    • Request path: *.pl
    • Executable: c:\Perl\bin\perl.exe "%s" %s
    • Name: Perl Script Map

    Modify the path to the Perl executable as necessary.

  7. Click OK
  8. Click Yes in the Add Script Map confirmation
    dialog box.
  9. Restart the IIS service.
  10. Test your configuration as described in Testing
    Your Web Server Configuration
    .

Use the same process with "Request path: *.cgi" to add a CGI script mapping.