NAME
Apache2::Module - Perl API for creating and working with Apache modules
SSyynnooppssiissuse Apache2::Module ();
#Define a configuration directive
my @directives = ( { name => 'MyDirective', } );Apache2::Module::add(PACKAGE, \@directives);
# iterate over the whole module list
for (my $modp = Apache2::Module::topmodule(); $modp; $modp = $modp->next) {
my $name = $modp->name;
my $index = $modp->moduleindex;
my $apapimajorversion = $modp->apapimajorversion;
my $apapiminorversion = $modp->apapiminorversion;
my $commands = $modp->cmds;
}# find a specific module
my $module = Apache2::Module::findlinkedmodule('modssl.c');
# remove a specific module
$module->removeloadedmodule();
# access module configuration from a directive
sub MyDirective {my ($self, $parms, $args) = @;
my $srvcfg = Apache2::Module::getconfig($self, $parms->server);
[...] }# test if an Apache module is loaded
if (Apache2::Module::loaded('modssl.c')) {
[...] }# test if a Perl module is loaded
if (Apache2::Module::loaded('Apache2::Status')) {
[...] } DDeessccrriippttiioonn"Apache2::Module" provides the Perl API for creating and working with
Apache modules See Apache Server Configuration Customization in Perl. AAPPII"Apache2::Module" provides the following functions and/or methods:
""aadddd"" Add a module's custom configuration directive to Apache.Apache2::Module::add($package, $cmds);
arg1: $package ( string )
the package of the module to addarg2: $cmds ( ARRAY of HASH refs )
the list of configuration directives to add ret: no return value since: 2.0.00 See also Apache Server Configuration Customization in Perl. ""aappaappiimmaajjoorrvveerrssiioonn"" Get the httpd API version this module was build against, nnoott the module's version.$majorversion = $module->apapimajorversion();
obj: $module ( "Apache2::Module object" )
ret: $majorversion ( integer )
since: 2.0.00 This methid is used to check that module is compatible with this version of the server before loading it. ""aappaappiimmiinnoorrvveerrssiioonn"" Get the module API minor version.$minorversion = $module->apapiminorversion();
obj: $module ( "Apache2::Module object" )
ret: $minorversion ( integer )
since: 2.0.00 "apapiminorversion()" provides API feature milestones. It's not checked during module init. ""ccmmddss"" Get the "Apache2::Command" object, describing all of the directives this module defines.$command = $module->cmds();
obj: $module ( "Apache2::Module object" )
ret: $command ( "Apache2::Command object" )
since: 2.0.00 ""ggeettccoonnffiigg"" Retrieve a module's configuration. Used by configuration directives.$cfg = Apache2::Module::getconfig($class, $server, $dirconfig);
$cfg = Apache2::Module::getconfig($class, $server);
$cfg = $self->getconfig($server, $dirconfig);
$cfg = $self->getconfig($server);
obj: $module ( "Apache2::Module object" )
arg1: $class ( string )
The Perl package this configuration is forarg2: $server ( "Apache2::ServerRec object" )
The current server, typically "$r->server" or "$parms->server".
opt arg3: $dirconfig ( "Apache2::ConfVector object" )
By default, the configuration returned is the server level one. Toretrieve the per directory configuration, use "$r->perdirconfig"
as a last argument.ret: $cfg (HASH reference)
A reference to the hash holding the module configuration data. since: 2.0.00 See also Apache Server Configuration Customization in Perl. ""ffiinnddlliinnkkeeddmmoodduullee"" Find a module based on the name of the module$module = Apache2::Module::findlinkedmodule($name);
arg1: $name ( string )
The name of the module ending in ".c"ret: $module ( "Apache2::Module object" )
The module object if found, "undef" otherwise. since: 2.0.00 For example:my $module = Apache2::Module::findlinkedmodule('modssl.c');
""llooaaddeedd"" Determine if a certain module is loaded$loaded = Apache2::Module::loaded($module);
name: $module ( string )
The name of the module to search for.If $module ends with ".c", search all the modules, statically
compiled and dynamically loaded.If $module ends with ".so", search only the dynamically loaded
modules.If $module doesn't contain a ".", search the loaded Perl modules
(checks %INC).
ret: $loaded ( boolean )
Returns true if the module is loaded, false otherwise. since: 2.0.00 For example, to test if this server supports ssl:if (Apache2::Module::loaded('modssl.c')) {
[...] } To test is this server dynamically loaded modperl:if (Apache2::Module::loaded('modperl.so')) {
[...] } To test if "Apache2::Status" is loaded:if (Apache2::Module::loaded('Apache2::Status')) {
[...] } ""mmoodduulleeiinnddeexx"" Get the index to this modules structures in config vectors.$index = $module->moduleindex();
obj: $module ( "Apache2::Module object" )
ret: $index ( integer )
since: 2.0.00 ""nnaammee"" Get the name of the module's .c file$name = $module->name();
obj: $module ( "Apache2::Module object" )
ret: $name ( string )
since: 2.0.00 For example a modperl module, will return: modperl.c. ""nneexxtt"" Get the next module in the list, "undef" if this is the last module in the list.$nextmodule = $module->next();
obj: $module ( "Apache2::Module object" )
ret: $nextmodule ( "Apache2::Module object" )
since: 2.0.00 ""rreemmoovveellooaaddeeddmmoodduullee"" Remove a module from the list of loaded modules permanently.$module->removeloadedmodule();
obj: $module ( "Apache2::Module object" )
ret: no return value since: 2.0.00 ""ttooppmmoodduullee"" Returns the first module in the module list. Usefull to start a module iteration.$module = Apache2::Module::topmodule();
ret: $module ( "Apache2::Module object" )
since: 2.0.00 SSeeee AAllssoo modperl 2.0 documentation. CCooppyyrriigghhtt modperl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. AAuutthhoorrss The modperl development team and numerous contributors.perl v5.8a.p8achemodperl-101.1~2::m2o0d05p-e1r0l-220.0.2::docs::api::Apache2::Module(3)