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

I've done a few projects with mod_perl and have always installed everything by hand from source. But, I have a Fedora 9 box which already had both installed and recently upgraded with yum but I am having trouble verifying the installation.

This is what my httpd.conf file did have:

RewriteEngine on RewriteRule /s/ /index.cgi [NC,QSA] <Directory "/path/to/site/docs"> Options Indexes Includes ExecCGI FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
I dropped this in hoping for a bit of a speed boost:
RewriteEngine on RewriteRule /s/ /index.cgi [NC,QSA] <Location "/path/to/site/docs/index.cgi"> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI </Location> <Directory "/path/to/site/docs"> # Options Indexes Includes ExecCGI FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
There was no noticeable - anything. In the past, when I have done something like this, I got a quick and easy CGI boost. But, in fact the site worked exactly as before. I did notice that making changes to index.cgi didn't require a restart of Apache (which used to be required with mod_perl). And so after doing:
# telnet localhost 81 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. HEAD / HTTP/1.0 HTTP/1.1 200 OK Date: Wed, 04 Feb 2009 23:24:38 GMT Server: Apache/2.2.9 (Fedora) Connection: close Content-Type: text/html; charset=ISO-8859-1 Connection closed by foreign host.
... I didn't see anything in the header indicating mod_perl. So, then I added a LoadModule directive to the httpd.conf and upon restarting Apache I got an error saying mod_perl was already loaded.

What am I missing here?

Replies are listed 'Best First'.
Re: Yum install of Apache & mod_perl
by perrin (Chancellor) on Feb 05, 2009 at 02:01 UTC

    First, changing index.cgi should not require a restart when using ModPerl::Registry. If it does, it's probably due to changing a module rather than index.cgi itself.

    To see if your script is running under mod_perl, just print out $ENV{MOD_PERL}. If it has no value, you're running under mod_cgi instead.

    At a guess, I'd say you need to reverse the order of those directives in your httpd.conf. It should go least specific to most.

      Printing out the environment verified that mod_perl was not running. So, I tried to see if I could get this to work:
      <Location /perl-status> SetHandler perl-script PerlResponseHandler Apache2::Status Order allow,deny Allow from all </Location>
      It did. So, after playing with the directives a little I realized the problem was actually with the rewrite rule, mod_perl wanted the location of the rewrite. So, while this did execute, it wasn't running under mod_perl:
      RewriteEngine on RewriteRule /s/ /index.cgi [NC,QSA] <Location "/path/to/site/docs/index.cgi"> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI </Location>
      And this simple change loaded mod_perl:
      RewriteEngine on RewriteRule /s/ /index.cgi [NC,QSA] <Location "/s/"> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI </Location>
      Obvious now... but isn't everything in hindsight?
Re: Yum install of Apache & mod_perl
by jethro (Monsignor) on Feb 05, 2009 at 00:58 UTC

    Did you check the apache logfiles?

    Here is a simple test whether mod_perl is running: You should be able to increment a variable declared with local or our and print it on the webpage. Without mod_perl the variable would always be 1. With mod_perl it should increment with every reread of the page (at least if I understand mod_perl correctly)