Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have installed Perl 5.6.1 and I have tested it by using the command-line (ie. c:\>Perl testscript.cgi and I get the correct output. However, when I go to the URL of the CGI (www.anywhere.com/cgi-bin/testscript.cgi) I get a HTTP-500 error message. Is there something that the Perl install or I left out? Somehow the system has to know to take the output to the browser. YES, I am new to Perl and especially on the WINDOWS2000 install.

Replies are listed 'Best First'.
Re: Perl for Win2000
by Speedy (Monk) on Feb 08, 2002 at 03:54 UTC
    Windows knows the script is a Perl script by the ending on the file name. Worse yet, for the Microsoft IIS Web server, having Windows know the extension is not sufficient; it must be specifically known within each IIS Web site application mapping. In contrast Unix/Linux looks for the "#!/usr/bin/perl\n\n" instruction on the first line to know what program to run. IIS ignores this line.

    The ActiveState default is to add the ".pl" extension to the IIS list of recognized Web applications. In your case you could test this by changing your file name from testscript.cgi to testscript.pl and see if it now runs in the browser.

    To manually add the .cgi extension to automatically execute Perl for your web site in IIS 5.0, follow the Programs/Administrative Tools/Internet Services Manager path. In the Internet Services Manager find the web site and get to its properties sheet from the menu popped up by a right click on the web site name.

    When you have the Properties sheet up, click on the "Home Directory" tab at the top. On that page look for the Configuration button below and to the left of the application field.

    Under the "App Mappings" tab Look down the list of extensions known to that IIS web server and see if the .pl extension is listed. If so, you can check out its properties (path, verb set, etc.) and use it as a model for a new application extension, except this time with the .cgi extension.

    On the executable path add "%s" %s for parameters. In my case the executable path is set to:
    D:\Perl\bin\Perl.exe "%s" %s
    which happens to be the location of Perl.exe on my system.

    Set the extension to .cgi, the Verbs set to "Limit to" with POST,GET,HEAD typed in, and the "Check that file exists" option is on with the "Use script engine" option off.

    With this change, IIS now knows what application to use to execute testscript.cgi

    ONE LAST CONSIDERATION: the security setting or Access Control List (ACL) for the directory holding the script and script must include a user that IIS can runs as -- normally IUSR_your-computer-name with at least read privileges. If you are not running the script in the normal INET path, this too can cause problems -- returning the message that you don't have permission to access the page.

    Hope this does it.

    Speedy
Re: Perl for Win2000
by trs80 (Priest) on Feb 08, 2002 at 01:34 UTC
    Check the following:
    1) Is your web server setup to handle .cgi files?
    2) Do you have the #!perl at the top of the script?
        (you have to have perl in path for that to work, if
         you don't have perl in your path use the full path.
         I recommend having it in your path.  ActiveState Perl
         adds it by default.)
    3) Are you printing the correct header?
    4) Look in the error log for the error message. This will
    hopefully contain useful information.
    

    If you are still having trouble post some of the code you are trying to get going.
Re: Perl for Win2000
by screamingeagle (Curate) on Feb 08, 2002 at 03:56 UTC
    i'm going to assume that you're using IIS on windows 2000, and ActiveState Perl here's what u need to check on the web server :
    a) open IIS, right-click the web site which you're programming the Perl script for, and select "Properties"
    b)Click the "Home Directory"
    c)Click the "Configuration" button", and then "ADD"
    d)in the resultant form which appears, choose the path to the PerlIIS.dll file which will be in , for example, c:\Perl\bin\PerlIIS.dll
    e) write ".cgi" in the "Extensions" input field
    f)Enter "PUT,DELETE" in the "Method Exclusions" input field (this field can also be left blank, since it is optional)
    Make sure that the "Script Engine" checkbox is checked (the other checkbox "Check that file exists" is optional) g)Lastly, stop and start the webserver for the changes to take effect (this is not a rule, but is recommended)
    h) Take a deep breath (mandatory), mutter a small prayer (optional), and try executing the file again...
    hope this helps :)
    (UPDATE: Looks like Speedy and I were thinking the same thing at the same time (except his mind was 2 minutes faster :-) )
Re: Perl for Win2000
by data64 (Chaplain) on Feb 08, 2002 at 01:01 UTC
    What webserver are you using? Apache, IIS, IPlanet or something else ?