in reply to How to configure Apache for running perl scripts.

Your combining two different ways of enable scripts:
<Directory "/var/www/html1"> ScriptAlias /cgi-bin/ "/var/www/html1" </Directory>
Enables your scripts under http://myIPaddress/cgi-bin/a.pl

AddHandler cgi-script .cgi .pl
Would enable your script to run everywhere in your DocumentRoot, but you'll also need:
<Directory "/var/www/html1"> Options +ExecCGI </Directory>
ScriptAlias sets up an alias, and does the +ExecCGI implicitly for the location.

If you don't want to be bound by your location, you need to explicitly add ExecCGI rights, and tell Apache to recognize the .pl extension.

Please consider using mod_perl though, if you want to be nice to your server...

Replies are listed 'Best First'.
Re^2: How to configure Apache for running perl scripts.
by munu (Novice) on Aug 06, 2004 at 14:43 UTC
    I have added "Options +ExecCGI" line as you told.
    But there are 2 similar places where i can add. And I have added the line in 2 places.

    But in error log it is still saying that "ExecCGI is not enabled".
      The error message means:
      • Apache has found the script at the url you specified
      • Apache recognizes the extension, and is trying to use the cgi-script handler
      • But Apache's failsafe mechanism which required that ExecCGI is explicitly enabled is blocking you

      Look for other 'Options' directives, maybe below your +ExecCGI one, that disable it again (maybe not explicitly, but possibly by specifying None).

      Please take a good look at Apache's documentation on the Option directive and Directory, Location and Files blocks. Also make sure there are no .htaccess files around which override your Options directives. Without your complete apache config it's hard to exactly determine the exact cause. If you can't find it with these tips, put it on the web somewhere, and send me a message with the url. I'll have a look at it for ya...

        I have commented out "AllowOverride None"
        But now I am getting follwing log message
        "malformed header from script. Bad header = hello: /var/www/cgi-bin/a.pl"

        a.pl contains
        #!/usr/bin/perl
        use strict;
        use CGI;
        my $q =CGI->new();
        print $q->header("text/html");
        print "hello";