Web Server Information

NAME

ActivePerl-faq6 - Web server information

DESCRIPTION

ActivePerl Web Server Configuration and Troubleshooting

General Web Server Configuration Issues

What web servers support ActivePerl?

Most Windows web servers that use the CGI standard or ISAPI will run ActivePerl scripts. The following servers are known to work with ActivePerl (known protocols in brackets):

Apache for Win32 [CGI, mod_perl]
http://www.apache.org
mod_perl home page: http://perl.apache.org
 
Microsoft Internet Information Server [CGI, ISAPI]
http://www.microsoft.com/WindowsServer2003/iis/default.mspx
 

Why does my ActivePerl script run from the command line, but not as a CGI script?

Usually, this means one of two things: either your system is misconfigured, or your script does not send the correct output for a CGI script.

Before you do anything else, check this list:

Check the information above with a script that you know produces the right output for the CGI protocol (scripts in this FAQ are a good first choice). Try it with your own script after you're sure the test script will work.

If you are sure the server is running the script, but it only generates error messages in your browser, there are some tools that may help you out. CGI::Carp is used to send debugging information to the browser or log file. Even if your script has a compilation error, it can usually intercept and report errors. To use CGI::Carp, include the following lines in your program:

    # The code in the BEGIN block will be executed very early
    # on, even before the rest of this script is parsed.
    #
    BEGIN {

        # Use the CGI::Carp module and import the carpout() function.
        #
        use CGI::Carp qw(carpout);

        # Send warnings and die messages to the browser.
        #
        carpout(STDOUT);

    }

If your script has an error, you may see something like this in the browser:

    [Wed Jun 3 09:32:28 1998] C:\inetpub\scripts\test.pl: Error message! at
    C:\inetpub\scripts\test.pl line 38.

Sometimes, it can be helpful to put yourself in somebody else's position. The libwww-perl bundle (LWP) is available from CPAN, but you can install it using the Perl Package Manager (PPM). LWP may be included with future releases of ActivePerl.

LWP includes the powerful lwp-request script, which lets you see things from the browser's perspective. Invoke lwp-request with the name of a URL to see the content of the response, as in lwp-request http://localhost. To inspect the headers of an HTTP response, invoke lwp-request with the -de switch:

    C:\>lwp-request -de http://localhost
    Date: Wed, 03 Jun 1998 13:37:31 GMT
    Accept-Ranges: bytes
    Server: Microsoft-IIS/4.0
    Content-Length: 4325
    Content-Location: http://localhost/Default.htm
    Content-Type: text/html
    ETag: "0c1e58b063bd1:1237"
    Last-Modified: Thu, 09 Apr 1998 12:09:28 GMT
    Client-Date: Wed, 03 Jun 1998 13:37:31 GMT
    Client-Peer: 127.0.0.1:0

This tool can be very helpful in figuring out exactly what your scripts are doing. Whatever you do, don't give up hope. It is, in fact, possible to get a Perl script running on your web server. Really.

Can't I put perl.exe in my CGI directory and call it in the URL? No!

First, the warning: do not do this. Really. Even if you don't understand why not, don't.

Now the explanation: the idea here is to put perl.exe in your CGI directory (however you configure that on your server), and use URL syntax like the following:

    http://soon.to.be.a.v