Making Apache2 execute CGI scripts, globally?

Posted by fraktalisman on Mon 14 Apr 2008 at 12:08

I have set up a Debian etch system with apache2, perl etc, but I cannot get apache to actually execute my scripts..

I want to be able to have .pl executed everywhere below /var/www . Everything is installed from the regular Debian packages, and all packages have been updated yesterday.

I first modified /etc/apache2.conf adding:

AddHandler cgi-script .cgi .pl
Options +ExecCGI

But still get the error message "403 Forbidden" in the browser, and the following logged:

Options ExecCGI is off in this directory

When I put the AddHandler and Options directives once more for the actual subdirectory, after restarting apache, the scripts are served for downloading, instead of being executed!

In the error log, I see:

(2)No such file or directory: 
exec of '/var/www/auktionator/admin/_rechte.pl' failed
Premature end of script headers: _rechte.pl

The script is chmodded 0755, and so are the directories in /var/

drwxr-xr-x  4 root root  4096 2008-04-08 13:06 www

I can execute the script from the command line, as follows:

perl -cw /var/www/auktionator/admin/_rechte.pl

My perl script starts correctly with:

#! /usr/bin/perl

which is the actual location of my perl binary.

I wonder if perl is configured correctly for apache to find it. How and where would I check this? There is a perl.load in

/etc/apache2/mods-available

and a link to it in

/etc/apache2/mods-enabled

This article can be found online at the Debian Administration website at the following bookmarkable URL:

This article is copyright 2008 fraktalisman - please ask for permission to republish or translate.