简体   繁体   中英

Apache mod_perl2 migration problem

I have an apache2 config file under /etc/init.d/apache2/conf.d/ which uses Perl Sections.

I am just trying to test if a module is loaded and configure apache as appropriate.

if( Apache->module( "mod_ssl.c" ) )
{
  ...
} else { ... }

This is the error I see though when restarting. I've also tried Apache2->method but get same error.

# /etc/init.d/apache2 restart Restarting web server: apache2Building Appliance configuration for Debian 5.0.7 Syntax error on line 73 of /etc/apache2/conf.d/foobar.conf: \\t(in cleanup) Can't locate object method "module" via package "Apache" (perhaps you forgot to load "Apache"?) at /etc/apache2/conf.d/foobar.conf line 357.\\n failed!

I don't think it is an @INC problem... And apache and libapache2-mod-perl2 packages are both installed. In fact if I comment that line out the rest of the perl actually runs fine.

perl -e 'print join "\n",@INC'
/etc/perl
/usr/local/lib/perl/5.10.0
/usr/local/share/perl/5.10.0
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.10
/usr/share/perl/5.10
/usr/local/lib/site_perl

I've also tried using the Apache::compat and "Apache2->module".
I suspect the problem is something is missing in startup.pl - but I've been googling and reading the mod perl docs and going round in circles. Any suggestions stackoverflow???

BTW- my startup.pl:

#!/usr/bin/perl -w
use strict;
use lib qw( /usr/lib/perl5/ /usr/lib/perl5/Bundle /usr/lib/perl5/Apache2 ) ;

BEGIN
{
    use Apache2 ();
    my $hostname = `hostname`;
}
use Apache;
use Apache::DBI ();
use Apache2::Const ();
use Apache2::Log ();
use Apache2::URI ();
use Apache2::compat;
use LWP::UserAgent ();
use DBI() ;

1;

从1.0移植到2.0 的文档建议使用Apache2::Module::loaded()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM