?
Solved

mod_perl2 loaded on startup but not loaded when running CGI scripts

Posted on 2007-10-01
3
Medium Priority
?
412 Views
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 startup.pl. That value is $ENV{MOD_PERL}: mod_perl/2.0.3 at /etc/httpd/conf/startup.pl 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.

httpd.conf
--------------------------
#
# 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/startup.pl

PerlModule ModPerl::PerlRun
PerlModule ModPerl::Registry

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

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

and startup.pl
--------------------------------------------------
use strict;

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

# preload and initialize CGI.pm
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;

1;
--------------------------------------------------

Apache: 2.0.54
mod_perl: 2.0.3
perl: 5.8.6
O/S: Linux my.host.name 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 athlon i386 GNU/Linux
0
Comment
Question by:jhill03
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
msklizmantas earned 1000 total points
ID: 19998273
hi,

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 http://www.example.com/foo/test.pl the server will map this into the file test.pl 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
  </Location>

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:

http://perl.apache.org/docs/1.0/guide/config.html#Alias_Configurations

regards,

m
0
 

Author Comment

by:jhill03
ID: 19998833
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.

Thanks!!!
0
 
LVL 6

Expert Comment

by:msklizmantas
ID: 19998862
no problem ;) my clear explanation comes from the docs ;)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
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…
Six Sigma Control Plans
Suggested Courses

807 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