locked
Host Perl on IIS 7 By CGI , windows serveice 2008 sp1 64x. Get result not expected. RRS feed

  • Question

  • User-286677902 posted

    Hi all

    I have just installed activeperl for Windows service 2008 sp1 64x, and have installed/enabled all components for iis7 on it.

    I have enable IIS CGI, and set the "script map"

    1. Request path: *.pl

    Executable: c:\Perl\bin\perl.exe "%s" %s

    Name: Perl Script (PL)

    Click OK

    Click Yes on the "enable ISAPI message"

    2. Request path: *.cgi

    Executable: c:\Perl\bin\perl.exe "%s" %s

    Name: Perl Script (CGI)

    Click OK

    Click Yes on the "enable ISAPI message

    when i try to run any *.pl scripts, i keep on getting the "file save" dialogue from my ie...do you know what may be wrong? would really appreciate your help on this issue...i would be willing to elaborate further if required.
     
    thx,

    Monday, May 30, 2011 11:00 PM

Answers

  • User-1672167363 posted

    Hello

    Have you checked this http://blogs.iis.net/wadeh/archive/2009/04/13/running-perl-on-iis-7.aspx guide

    for perl install?

    Question when you ran the Active State perl install did you say yes to create a Windows File Association?

    If you created the Windows File Association re run the installer and un-select the File Association.

    And check Wade guide for steps to create the handler and for perl you need a *.cgi and *.pl

    mapping along with enable the execution of "cgi" which by default is disabled.

    For your perl scripts and IIS Server make sure the first output is Content: "text/plain"; other wise

    you will get gateway errors on execution.

    Additionally you need to add the IUSR IIS_USERS permissions to the perl directories.

    Martin

     

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Tuesday, May 31, 2011 2:29 AM
  • User-286677902 posted

    I follow this link

    http://www.websitepanel.net/kb/installing-and-running-active-perl-runtime-as-isapi-on-microsoft-iis-7.0

    setting my windows server 2008 IIS 7.0

    and the perl is work now.

    detail setting is below:

    1. install perl path "C:\perl"
    2. not select PPM
    3. uncheck all options
    4. install Role IIS
    5. install IIS features
    6. enable all feature under  "Internet Infomation Services"
    7. run inetmgr
    8. add script handle  mapping
      *.pl
      c:\perl\bin\perl.exe %s %s
      ps. here no need "%s" just %s is ok
    9. move perl file to path "c:\inetpub\wwwroot"
    10. restart iis
    11. open ie test it
    12. every done :)
    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Thursday, June 9, 2011 5:32 AM

All replies

  • User-286677902 posted

    I try it in windows 7 enterprise, with IIS 7.5

    if I use localhost, the script work.

    but when I use machineName in URL, the "file save" dialogue show again.

    Tuesday, May 31, 2011 1:32 AM
  • User-1672167363 posted

    Hello

    Have you checked this http://blogs.iis.net/wadeh/archive/2009/04/13/running-perl-on-iis-7.aspx guide

    for perl install?

    Question when you ran the Active State perl install did you say yes to create a Windows File Association?

    If you created the Windows File Association re run the installer and un-select the File Association.

    And check Wade guide for steps to create the handler and for perl you need a *.cgi and *.pl

    mapping along with enable the execution of "cgi" which by default is disabled.

    For your perl scripts and IIS Server make sure the first output is Content: "text/plain"; other wise

    you will get gateway errors on execution.

    Additionally you need to add the IUSR IIS_USERS permissions to the perl directories.

    Martin

     

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Tuesday, May 31, 2011 2:29 AM
  • User-286677902 posted

    Thanks for you response.

     Let me check the link you just give to me.

    Tuesday, May 31, 2011 3:32 AM
  • User521890537 posted

     You can try mapping Isapimodule -> C:\Perl\bin\PerlEx30.dll

    Tuesday, May 31, 2011 4:07 AM
  • User-286677902 posted

    Thanks Kctt,

    I think the reason is I use the Perl 64

    now Im trying to install the perl 32 5.12.3

    Tuesday, May 31, 2011 4:10 AM
  • User-1672167363 posted

    Hello,

    Yes, There are many problems with using  Perl X64 versions it is better to use Perl X86.

    Martin

     

    Tuesday, May 31, 2011 4:23 AM
  • User-286677902 posted

    Hi Martin,

     I follow the link what you send to me.

    install the perl X86

    at hendler mappings, I add the Module Mapping that "*.pl" mapping to "C:\Perl\bin\PerlEx30.dll"

    and remove the script map that "*.pl" mapping to "C:\Perl\bin\Perl.exe "%s" %s"

     I get 500.0  

    in detail it say "The authenticated user does not have permission to use this DLL."

    but, I already add the IIS_IUSRS user to C:\Perl User

    Tuesday, May 31, 2011 4:42 AM
  • User-286677902 posted

    by the way,

    the perlex30.dll cannot add "%s" %s"

    Tuesday, May 31, 2011 4:47 AM
  • User-286677902 posted

    it seems not just because 64bit activeperl.

    after I install the activeperl.

    add the perlex30.dll module mapping. the server return 500.0

    and if I add perl.exe "%s" %s script mapping. the localhost work correct.

    but if I use my machinename in url, will pop the download box

    Tuesday, May 31, 2011 4:51 AM
  • User-1672167363 posted

    Hello,

    Check this post also http://forums.iis.net/p/1178048/1981396.aspx#1981396 .

    As I posted early on you have two account that require access  IUSR then IIS_USRS permissions to the perl directories.

    The IUSR and IIS_USRS need to have permissions in IIS Server and the Web Sites for access

    the permissions are read,execute,list.

    The IUSR and IIS_USRS need to to have permissions and access to the C:\Windows\Temp folders

    and require read,execute,list and write.

    In addition to the permissions check that the perl path is after the C:\Windows...\ and not before C:\Windows...\

    you will experience very slow start up of the windows system the path also prevents checking for Windows Commands to

    use to open perl or other files.

    Martin

     

     

     

    Tuesday, May 31, 2011 5:10 AM
  • User-286677902 posted

    Thanks HCamper,

    Let me check the link you send to me.

    Tuesday, May 31, 2011 5:47 AM
  • User-286677902 posted

    Hi HCamper,

    Thanks for your response at first.

    unfortunately, the script still not exec when the url not localhost.

    It pop the savefile dialogureBox

    I follow these step:

    1. install perl -- ActivePerl-5.12.3.1204-x86,

    2. perl install Path: C:\Perl

    3. set IUSR and IIS_IUSRS permissions, read,execute,list for C:\Perl

    4. Add CGI to Role "Web Server(IIS)"

    5. Create perl file "perlhelloworld.pl", which include "print "Content-type: text/plain\n\n";"

    6. Add Module mapping, Request path: *.pl ; executable c:\Perl\bin\perlex30.dll

    7. Set IUSR and IIS_IUSRS permissions, read,execute,list for this web site

    8. Set IUSR and IIS_USRS permissions  C:\Windows\Temp folders, read,execute,list, write

    9. Set the DefaultAppPool , Enable 32-Bit Applications : true

    PS.

    1)  I still set the DefaultAppPool, .netframework : v4.0 ; Identity : NetworkService ; Load User Profile : false

    2)  I remove the CgiModule Handler mappings.

    Tuesday, May 31, 2011 10:45 PM
  • User-286677902 posted

    BTW,

    when I set isapimodule and cgimodule, the locahost link work

    but, after I replace localhost to server name, the perl script will not exec but pop a download dialogure box.

    and, isapimodule can not follow paramteters. its means localhost?XXX not work in isapimodule

    Wednesday, June 1, 2011 4:04 AM
  • User-1672167363 posted

    Hello,

    The current failures likely are " DefaultAppPool, .netframework : v4.0 ; Identity : NetworkService ; Load User Profile : false"

    change the Application Pool settings  to Net 2.0 Framework and select Classic Mode and select the Identity.

    Undo the setting for Set the DefaultAppPool , Enable 32-Bit Applications : true.

    Check this guide for settings http://www.iis.net/ConfigReference/system.applicationHost/applicationPools/applicationPoolDefaults .

    And use this for operations http://learn.iis.net/page.aspx/624/application-pool-identities/ .

    General Note: You can have several Handlers and mappings for perl to use CGI and SCRIPT you create

    each with unique name and settings.

    Martin

     

    Wednesday, June 1, 2011 8:35 AM
  • User-286677902 posted

    Thanks Martin again.

    I set the Default AppPool as you said.

    but my current VM is windows server 2008 sp1

    I cannot find the "ApplicationPoolIdentity " in the Identity drop down box in the pool advance setting.

    I think it just in 2008 sp2.

    So, my current setting is like below

    .net framework version : v2.0
    Enable 32-bit applications : true
    Managed Pipeline Mode : classic
    Name: DefaultAppPool
    Identity: LocalService (I use this setting, because as I know this setting has the most powerful)
    Load User Profile: False

    But the result is nothing changed.

    So, I try everything in my local machine (window 7 enterprise, IIS 7.5)

    I set Isapi mapping and CGI mapping.

    and the pool setting is totally same to you said.

    below is my test:

    1. http://localhost/PerlTest/PerlHelloWorld.pl

    I get result :

    Hello world!
    
    Press the Enter key to exit.
    

    2. http://myServerName/PerlTest/PerlHelloWorld.pl

    I get result :

    A pop box. title is : Do you want to open or save PerlHelloWorld.pl (43 bytes) from myServerName? (in Server 2008 sp1 always get this result, even I use local host)

    Below is my PerlCode:

    PerlHelloWorld.pl

    #!/usr/bin/perl
    print "Content-type: text/plain\n\n";
    print "Hello world!\n\n";
    print "Press the Enter key to exit.\n";
    <>; #pause

     
    Wednesday, June 1, 2011 10:24 PM
  • User-286677902 posted

    Why the perl host on IIS work correct in LocalHost url.

    And not work in the ServerName URL

    Is there the reason not the handler mapping but the IIS publish issue?

    Friday, June 3, 2011 5:37 AM
  • User-1672167363 posted

    Hello,

    General Note: For Web Servers and Script Engines have pretty much the same requirements for operations:

    A ) A fully defined path to the Script Engine.

    B) A short path to the Script Engine.

    C) A method to deliver proper headers for first request.

    D) A method to allow passing parameters as part of the Scripting Engine.

        The format for parameters and passing values follow the general

            rules for C, C++ and Main Function .

            Reference: http://en.wikipedia.org/wiki/Main_function 

     E) A mapping of an extension or Mime type that is a form of request for files.

    F) Enabling the Web Server to allow the execution of the Script Engine.

    G) Security restrictions for User Accounts, File System access that are in effect to protect the System.

    H) The items A-G are true for PHP,Perl, Ruby,Python and others.

    I) There may be variations for types of Web Servers, but you can generalize that A-G must be handled first.

    The problem is likely that you have not enabled the Handler in IIS Server or in the location the script is running from.

    Yes The items A-I from above are a long description for rules. If you use A-I as a  general Work Flow all the scripting engines

     will work.

    Martin

     

     

    Friday, June 3, 2011 9:41 AM
  • User-286677902 posted

    Now, I set the website ISAPIFilters

    Name: PerlISAPIFilter

    Executable: C:\Perl\bin\perlis.dll

    after all ISAPIFilters setting, I reset iis

    Access the perl file by IE again.

    the download Dialogure box has gone.

    but, I get new error. like below

    I have check the Perlis.dll permissions. I have add the IUSR and IIS_IUSRS , and give them full control right.

    ======================================================================= 

    Error Summary :

    HTTP Error 500.0 - Internal Server Error

    Calling GetProcAddress on ISAPI filter "C:\Perl\bin\perlis.dll" failed

    Detailed Error Information

    Module IIS Web Core
    Notification Unknown
    Handler ActiveState Perl for .pl
    Error Code 0x8007007f
    Requested URL http://localhost:80/perlTest/PerlHelloWorld.pl
    Physical Path C:\TextCatIIS\PerlHelloWorld.pl
    Logon Method Not yet determined

    Logon User

    Not yet determined

    Most likely causes:

    • The ISAPI Filter has dependencies that are not available on the Web server.
    • IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
    • IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
    • IIS was not able to process configuration for the Web site or application.
    • The authenticated user does not have permission to use this DLL.

    Things you can try:

    • Try running Reskit tool "depends" on the ISAPI DLL.
    • Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.
    • Check the event logs to see if any additional information was logged.
    • Verify the permissions for the DLL.
    • Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.

    ======================Web.config===============================================================

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <defaultDocument>
                <files>
                    <add value="PerlHelloWorld.pl" />
                </files>
            </defaultDocument>
        </system.webServer>
    </configuration>

    Tuesday, June 7, 2011 3:05 AM
  • User-286677902 posted

    The Location section in applicationHost.config is like below:

    <location path="Default Web Site/perlTest">
            <system.webServer>
                <handlers>
                    <remove name="CGI-exe" />
                    <remove name="ISAPI-dll" />
                    <remove name="Perl Script (PL)" />
                    <remove name="Perl Script (CGI)" />
                    <add name="ActiveState Perl for .pl" path="*.pl" verb="*" modules="IsapiModule" scriptProcessor="C:\Perl\bin\PerlEx30.dll" resourceType="Either" requireAccess="Script" preCondition="bitness32" />
                </handlers>
            </system.webServer>
        </location>
        <location path="Default Web Site">
            <system.webServer>
                <handlers>
                    <remove name="Perl Script (PL)" />
                    <add name="Perl Script (PL)" path="*.pl" verb="GET,HEAD,POST" modules="CgiModule" scriptProcessor="c:\Perl\bin\perl.exe &quot;%s&quot; %s" resourceType="Unspecified" />
                    <add name="Perl ISAPI" path="*.pl" verb="*" modules="IsapiModule" scriptProcessor="C:\Perl\bin\perlis.dll" resourceType="Unspecified" preCondition="bitness32" />
                </handlers>
                <isapiFilters>
                    <filter name="PerlIsapiFilter" path="C:\Perl\bin\perlis.dll" preCondition="bitness32" />
                </isapiFilters>
            </system.webServer>
        </location>

    Tuesday, June 7, 2011 5:46 AM
  • User-1672167363 posted

    Hello,

    When you add directories "C:\TextCatIIS\" that are not in IIS Server 

    you need to manually add the permissions for the IUSR and IIS_USRS or other accounts.

    Also do not add the perl script as default document.

    For the handlers remove current or duplicate entries.

    Currently you need to restore the handler that installer created.

    Default or basic mapping of *.pl  and point to "C:\Perl\bin\perl.exe" "%s" %s with name "Perl Script" 

    restrictions of file with verbs Get,HEAD,POST and execution as script.

    After the settings have been set go to the Web Site you created TextCatIIS and enable the handler.

    Check the ISAPI Restrictions pane and check that there is a single entry with the path and parameters from above.

    Check your test script.

    If the test script works then you can add addtional ISAPI  mapping as shown in the guide.

    You can have mappings for Perl to handle file or file & folder each with Unique Name and types of actions or restrictions.  

    Yes, The steps for creating handlers and mapping's can be confusing at first. You can make this work. 


    Martin

     

     

     

    Tuesday, June 7, 2011 11:32 AM
  • User-286677902 posted

    Thanks HCamper for you response me.

    I have create a "perltest.pl" file in "C:\inetpub\wwwroot" location

    ====================================perltest.pl=========================================

    #!/usr/bin/perl
    print "Content-type: text/plain\n\n";
    print "Hello world!\n\n";
    print "Press the Enter key to exit.\n";
    <>; #pause

    =====================================================================================

    My current environment :

    • windows 7 Enterprise
    • IIS 7.5
    • perl 5, version 12, subversion 3 (v5.12.3) built for MSWin32-x86-multi-thread

    After that, I do follow steps:

    1. remove IIS and IE
    2. reinstall the IIS feature and IE 9
    3. enable CGI feature
    4. add perl script handler mapping,
      *.pl
      C:\Perl\bin\perl.exe "%s" %s
    5. set Default AppPool
      set "Managed Pipeline Mode" = Classic
      set "Enable 32-Bit Applications" = True
    6. Browse http://localhost/PerlTest.pl correct
      return
    7. Browse http://MyServer/PerlTest.pl fail (MyServer is my Compter Name)
      Show a download box, click "Yes" the perl file will be download.

     Base on these step:

    1. Add IIS ISAPI Filters Feature
    2. Add ISAPI Filters
      *.pl
      c:\perl\bin\perlis.dll
    3. Browse http://localhost/PerlTest.pl and Browse http://MyServer/PerlTest.pl fail (MyServer is my Compter Name) all Fail
      Show 500.0

      HTTP Error 500.0 - Internal Server Error

      Calling GetProcAddress on ISAPI filter "C:\Perl\bin\perlis.dll" failed

    What I want is get the result when I use Mechina Name to access IIS

    This issue follow me like a ghost almost a week, its very strange I have try all the setting.

    Thanks for your help again.

      

       

    Wednesday, June 8, 2011 3:22 AM
  • User-286677902 posted

    It looks like

    if I use CGI, the handle mapping not working when the URL link not use localhost but serverName

    if I use ISAPI, its just work in ISAPI Filters, and the perlis.dll can not be access.

    Wednesday, June 8, 2011 5:27 AM
  • User-1672167363 posted

    Hello,

    You have to check the subtle differences

    using the path to Perl as "C:\Perl\bin\perl.exe" "%s" %s

    with proper quotes  is different than  C:\Perl\bin\perl.exe "%s" %s .

    Note: The handlers appear in two places in Features View  the Machine and Default Web Server.

    After you make the handler changes you need to enable the handler in the Default Web Site.

    The 500 error is permissions problem for the  Default Web Server for Application Pool and or Identity used.

    Check the link for Perl and Buzilla there is a picture showing the ISAPI restrictions and the

    path to Perl will appear in that location you need to check that there are no un-named duplicates and path is correct.

    Martin

     

     

    Wednesday, June 8, 2011 1:44 PM
  • User-286677902 posted

    Thanks for you response Martin,

    I have try the path "C:\Perl\bin\perl.exe" "%s" %s

    but, give me same result.

    and I find in the before, I have not set the machine handle mapping.

    after I set the handle mapping in machine part.

    it returns same result too.

    =======================================================================

    after them all,

    1. I remove the perl script mapping

    2. I add module mapping

         *.pl

         FastCgiModule

         "C:\Perl\bin\perl.exe" "%s" %s

    3. I get  500.0 result

        

    Wednesday, June 8, 2011 10:12 PM
  • User-1672167363 posted

    Hello,

    I suggest you check the Jetstat @ dot com web site

    they have a free dignostics tool called ASP Diag.

    The diag tool can be used to check server variables PHP and perl.

    The Asp Diag may help you work out the perl issues.

    General Disclaimer: The ASP Diag is not a Microsoft Supported Product.

    For a Microsoft Supported note check this http://support.microsoft.com/kb/245225 .

    The 500 error is not that usefull look at list http://support.microsoft.com/kb/943891

     so use this guide http://learn.iis.net/page.aspx/267/how-to-use-http-detailed-errors-in-iis-70/ .

    To get more details for the types of errors.

    Hope this gets you going.

    Martin

     

     

    Wednesday, June 8, 2011 10:24 PM
  • User-286677902 posted

    in the post  "Running Perl on IIS 7   "

    http://blogs.iis.net/wadeh/archive/2009/04/13/running-perl-on-iis-7.aspx

    author said  

    "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."

    So, is there use ISAPI is better than FastCGI in host perl on iis?

    Wednesday, June 8, 2011 11:02 PM
  • User-1672167363 posted

    Hello,

    If you look later in the post additional notes:

    "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."

    His conclusion was the Active state ISAPI runs great in comparision to FastCGI and perl.

    You can have both the ISAPI and FastCGI handlers with mappings using different names and types of access.

    The current problem is getting at least one of the possible (pl cgi)  Handlers and Mappings working for Web Server settings then in Web Sites.

    The Perl Script Handler using a *.pl or *.cgi map with path to perl.exe

     or

     *.pl path to perl dll then you need to enable in Machine aka IIS Server then enable in Web Site and set the correct permissions.

    The Microsoft Support article maybe words the steps better that the post by Wade ?

    Martin

     

     

    Wednesday, June 8, 2011 11:39 PM
  • User-286677902 posted

    Now , the helloworld.pl is work correct in windows 7 and IIS 7.5 with CGI.

    I remove the Perl, and matnual remove c:\perl folder.

    after that I reinstall the perl,

    1. not select PPM

    2. uncheck all of the options prompted

    3. enable all feature under "Internet Infomation Services"

    Thursday, June 9, 2011 1:41 AM
  • User-286677902 posted

    I follow this link

    http://www.websitepanel.net/kb/installing-and-running-active-perl-runtime-as-isapi-on-microsoft-iis-7.0

    setting my windows server 2008 IIS 7.0

    and the perl is work now.

    detail setting is below:

    1. install perl path "C:\perl"
    2. not select PPM
    3. uncheck all options
    4. install Role IIS
    5. install IIS features
    6. enable all feature under  "Internet Infomation Services"
    7. run inetmgr
    8. add script handle  mapping
      *.pl
      c:\perl\bin\perl.exe %s %s
      ps. here no need "%s" just %s is ok
    9. move perl file to path "c:\inetpub\wwwroot"
    10. restart iis
    11. open ie test it
    12. every done :)
    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Thursday, June 9, 2011 5:32 AM
  • User-1672167363 posted

    Hey @ felixz,

    Glad you got the perl going.

    Cheers :)

    Martin

     

    Thursday, June 9, 2011 10:18 AM
  • User1073881637 posted

    Thanks for the handy reference thread.  I was able to get PERL running.  Anyone know how to secure for shared hosting?

    http://forums.iis.net/p/1179875/1988997.aspx

    visit this thread.

    http://www.iislogs.com/steveschofield/hosting-perl-on-iis-7.x-thread (blog I wrote referencing this thread!)

    Thursday, July 14, 2011 7:37 AM
  • User-1672167363 posted

    Hello @ Steve,

    The previous suggestions comments for this http://forums.iis.net/p/1179875/1988997.aspx post

          for Perl and Shared Hosting have been moved to

    a New Post in PHP Community Forum.

    Martin

     

     

    Saturday, July 16, 2011 2:21 PM