mod_perl2 loaded on startup but not loaded when running CGI scripts

Posted on 2007-10-01
Last Modified: 2012-05-05
Running into an issue when trying to get mod_perl applied to the scripts in my /var/www/cgi-bin directory.
Apache is up and running with no errors, it just doesn't appear that mod_perl is being utilized for the scripts in my cgi-bin directory, even though it (mod_perl2) is loaded on startup. I verified that by 'warning' the value of $ENV{MOD_PERL} to the error_log via That value is $ENV{MOD_PERL}: mod_perl/2.0.3 at /etc/httpd/conf/ line 3.

So given that, I've probably got a bad/incomplete setting for mod_perl to be utilized for my scripts. I just can't seem to find it and not sure where to look... getting pointed in the right direction would be a great assistence...

Here's some entries in the various .conf file... Note: I haven't included the entire .conf file(s), but I'm hoping I've provided enough that either someone can spot the error or can say "You also need..." -- Thanks.

# Load config files from the config directory "/etc/httpd/conf.d".
Include conf.d/*.conf
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot "/var/www/html"
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
ScriptAlias /cgi/ "/var/www/cgi-bin/"

in perl.conf
# This will allow execution of mod_perl to compile your scripts to
# subroutines which it will execute directly, avoiding the costly
# compile process for most requests.

PerlRequire /etc/httpd/conf/

PerlModule ModPerl::PerlRun
PerlModule ModPerl::Registry

<Directory cgi-bin>
  AddHandler perl-script .cgi
  PerlResponseHandler ModPerl::PerlRun
  PerlOptions +ParseHeaders
  Options ExecCGI
  allow from all

<Directory htdocs>
  AddHandler perl-script .cgi
  PerlResponseHandler ModPerl::PerlRun
  PerlOptions +ParseHeaders
  Options ExecCGI
  allow from all

use strict;

warn "\$ENV{MOD_PERL}: $ENV{MOD_PERL}"; # verify that mod perl is being loaded

# preload and initialize
use CGI();
CGI->compile(qw(cookie param header redirect));

# preload DBI
use Apache::DBI;
use DBD::mysql;

# preload MD5;
#use MD5;

$Apache::DBI::DEBUG = 2;


Apache: 2.0.54
mod_perl: 2.0.3
perl: 5.8.6
O/S: Linux 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 athlon i386 GNU/Linux
Question by:jhill03
    LVL 6

    Accepted Solution


    quick shot from documentation on mod_perl1 version, but it might be applied to your case too i think:

    The ScriptAlias and Alias directives provide a mapping of a URI to a file system directory. The directive:

      Alias /foo /home/httpd/foo

    will map all requests starting with /foo onto the files starting with /home/httpd/foo/. So when Apache gets a request the server will map this into the file in the directory /home/httpd/foo/.

    In addition ScriptAlias assigns all the requests that match the URI (i.e. /cgi-bin) to be executed under mod_cgi.

      ScriptAlias /cgi-bin /home/httpd/cgi-bin

    is actually the same as:

      Alias /cgi-bin /home/httpd/cgi-bin
      <Location /cgi-bin>
        SetHandler cgi-script
        Options +ExecCGI

    where latter directive invokes mod_cgi. You shouldn't use the ScriptAlias directive unless you want the request to be processed under mod_cgi. Therefore when you configure mod_perl sections use Alias instead.

    more information:



    Author Comment

    Yep. I figured all that out late last night, but that's exactly what the problem was.

    I couldn't have stated it quite so clearly as you though... I just figured out it was the ScriptAlias directive that was causing the issue.

    LVL 6

    Expert Comment

    no problem ;) my clear explanation comes from the docs ;)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
    If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now