The problem: Apache is generating “File does not exist” within its error.log and the message “Object not found” (The requested URL was not found.  Error number 404.) while attempting to call a perl module from a brower.

 

Since I am new with mod_perl, and somewhat with familiar perl, I must confess the following problem has baffled me while someone else may quickly see what is being done wrong.  Appreciation is expressed in advance to anyone who can tell me what the problem might be or recommends a remedy.

 

Below you’ll see the path settings found in the various configurations files.  I have followed the string of recommendations found in the on-line documentation (from perl.apache.org, etc.) and but have also made minor adjustments relevant to this particular server’s configuration.  I understand that I am providing some information (not much) which is not relevant to the immediate problem but can assist to give an overview the operating environment as a whole.

 

Here are the details:

 

Given:

 

1) The file httpd.conf contains the lines:

 

ServerRoot "/etc/httpd"

 

....

 

Include conf.d/*.conf

 

(The presence of this include statement is before the invocation of the various LoadModules found in most httpd.conf files. Hence, the perl environment is set early in the Apache initialization process.)

 

2) and the file /etc/httpd/conf.d/perl.conf contains the lines:

 

LoadModule perl_module modules/mod_perl.so

PerlRequire "/var/www/perl/startup.pl"

 

....

 

Alias /perl/ /var/www/perl/

<Directory /var/www/perl>

    SetHandler perl-script

    PerlHandler ModPerl::Registry::handler

    PerlOptions +ParseHeaders

    Options +ExecCGI

</Directory>

 

<Location /CurrDate>

    SetHandler per-script

    PerlResponseHandler MyApache::CurrDate

</Location>

 

3) and the file /etc/httpd/perl/startup.pl contains the line:

 

use lib qw(/var/www/perl);

 

4) and the file /etc/httpd/perl/MyApache/CurrDate.pm contains the line:

 

package MyApache::CurrDate;

 

then why does /var/httpd/error.log report:

 

[error] [client 192.168.0.100] File does not exist: /var/www/html/CurrDate

 

So, in otherwords, why is does the URL //192.168.0.100/CurrDate 'not' invoke CurrDate.pm from the anticipated directory of /var/httpd/perl/MyApache?

Notice the Apache error log indicates that it is trying to access a file under the directory /var/www/html/ rather than /var/www/perl/.  This is done even though the perl.conf file includes the <Location> directive which should redirect program control to the respective perl module.  And, the startup script spec’s the parent directory where perl modules can be found.

 

Incidentally, the intent of MyApache/CurrDate.pm is to test the existing mod_perl environment for its ability to run handlers.  (Better said, it is to test my ability and the present set up.  The system is being initialized for the first time on this system.  Another version of CurrDate.pm, in the form of a script, was executable from a browser.  So, Apache and Perl are likely set up correctly.)  Security of the files shouldn't be a problem.  The permissions of all respective files have been set to assure they ought to be both readable and executable from a browser.

 

Now when the browser is pointed to a different address, i.e. //192.168.0.100/perl/CurrDate, then partial progress 'maybe' occurring for

an Apache exception indicates:

 

[error] 13440: ModPerl::Registry: /var/www/perl/CurrDate.pm not found or unable to stat

 

So it appears, with this later URL address, access to modperl is being accomplished (!?).  Granted, yet another problem may exists; namely, the one generated by the ModPerl Registry method.  Hence, I may have two problems to resolve rather than just the one.

 

An article (it is entitled “Getting Your Feet Wet with mod_perl”) declares a handler with the syntax “PerlResponseHandler ModPerl::Registry” where I have used a different syntax.  It was “PerlHandler ModPerl::Registry::handler” for the former would not work on this system.  The later was able to successfully run a script.  This change was made to the directory /var/www/perl and not to the location called by /CurrDate name space.  This may not have relevance to the problem at hand.

 

I understand Apache directives have a precedence.  However, I have sequenced the order of the directories in various ways without a resolution or apparent different effect.  Any suggestions?

 

Thank you for your assistance.

#!/usr/bin/perl
#
# FileID:               /perl/MyApache/currDate.pm
# Edition:              1600.08012003
# Editor:               Steve Davis
# Install.:             Powder Springs, GA
# Purpose:              To display the current date
#
package MyApache::CurrDate;

use strict;
use warnings;

use Apache::RequestRec ();
use Apache::RequestIO ();
use Apache::Const -compile => qw(OK);

sub handler {

   my ($SEC,$MIN,$HOUR,$MDAY,$MON,$YEAR,$WDAY,$YDAY,$ISDST) = localtime(time);
   my $CURR_MONTH = 
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") [$MON + 1];
   my $CURR_YEAR  = $YEAR + 1900;
   my $CURR_DAY = (localtime)[3];
   my $CURR_YEAR = (localtime)[5] + 1900;
   
   my $r =shift;
   $r->content_type('text/plain');
   print($CURR_DAY . " " . $CURR_MONTH . " " . $CURR_YEAR . "\n");

   return Apache::OK;
}
1;
#
# FileID:               /etc/httpd/conf.d/perl.conf
# Edition:              2030.30122002
# Editor:               Steve Davis
# Install.:             Powder Springs, GA 
# Purpose:              To set the operating environmrnt of perl under Apache 2.X.
#
# Notes:
#
# Maintenance history:
#

LoadModule perl_module modules/mod_perl.so
PerlRequire "/var/www/perl/startup.pl"

PerlSetEnv PERL_DESTRUCT_LEVEL -1
#
# PerlSetVar StatusOptionsAll On
PerlSetVar StatusDumper On
PerlSetVar StatusPeek On
PerlSetVar StatusLexInfo On
PerlSetVar StatusDeparse On
PerlSetVar StatusTerse Off
PerlSetVar StatusTerseSize On
PerlSetVar StatusTerseSizeMainSummary On
# PerlSetVar StatusGraph
#
PerlModule Apache2
#
Alias /perl/ /var/www/perl/
<Directory /var/www/perl>
    SetHandler perl-script
    PerlHandler ModPerl::Registry::handler
    PerlOptions +ParseHeaders
    Options +ExecCGI
</Directory>

<Location /CurrDate>
    SetHandler per-script
    PerlResponseHandler MyApache::CurrDate
</Location>

Reply via email to