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

I installed CGI.pm just a while ago. Now it works fine when I run a *.cgi file. But when I run a *.pl file with 'use CGI;', I get an Internal Server Error. How do I configure the server to accept perl-scripts (*.pl file)with CGI.pm or do you recommend me to keep the existing configuration?

Thank you.

--Zenon Zabinski

Replies are listed 'Best First'.
Re: Help with CGI/Perl
by infoninja (Friar) on Jun 28, 2000 at 22:35 UTC
    I'm assuming that you're running Apache - YMMV if you're using a different server.
    From Apache documentation:
    "Any file that has the mime type application/x-httpd-cgi or handler cgi-script (Apache 1.1 or later) will be treated as a CGI script, and run by the server, with its output being returned to the client. Files acquire this type either by having a name containing an extension defined by the AddType directive, or by being in a ScriptAlias directory."
Re: Help with CGI/Perl
by Maclir (Curate) on Jun 29, 2000 at 05:07 UTC
    A few things. This has notning to do with CGI.pm, rather, how your server has been set up.

    1) Have you looked in the Apache error log (normally in /usr/local/apache/logs/error_log). Tail it - you will see the real errors.

    2) Have you allowed *.pl to be run as cgi programs? Look in httpd.conf in /usr/local/apache/conf. It may not recognise things ending in .pl as a script.

    We have the convention that scripts that are *.pl are run under mod_perl.

    Ken

Re: Help with CGI/Perl
by davorg (Chancellor) on Jun 29, 2000 at 12:08 UTC

    Another little tip. Putting use CGI::Carp qw(fatalsToBrowser); in your script will usually display CGI errors in your browser. This makes debugging much easier.

    --
    <http://www.dave.org.uk>

    European Perl Conference - Sept 22/24 2000
    <http://www.yapc.org/Europe/>
Re: Help with CGI/Perl
by tenatious (Beadle) on Jun 28, 2000 at 23:30 UTC

    Keep the existing configuration. It is purely a naming convention, and doesn't mean anything at all. Many people reserve the .pl suffix for perl libraries instead of CGI scripts.

    Besides, messing around with the server isn't as much fun as actually programming. (IMO)

Re: Help with CGI/Perl (access.conf)
by ybiC (Prior) on Jun 29, 2000 at 19:39 UTC
    To expand a bit on infoninja's response, Apache on Debian includes the following in /etc/apache/access.conf :
    <Directory /usr/lib/cgi-bin> Options ExecCGI </Directory>
    Any executable script (#!/usr/bin/perl) placed in that directory will run, regardless of filename extension.

    If you use CGI::Carp, as davorg wisely suggested, consider removing it once debugging is done. From a security standpoint, you may not want possible errors going out to the world.


        cheers,
        ybiC
Re: Help with CGI/Perl
by csorensen (Beadle) on Jun 29, 2000 at 02:44 UTC
    is there a cgiwrapper installed ?