libapa...:Module(3pm)
π NAME π
Apache2::Module β the Perl API for creating and working with Apache modules π«Ά (it lives in the libapa...:Module(3pm) manual page, yes bestie, that's the one you're reading right now).
β¨ Synopsis β¨
okay so here's the whole vibe, copy-paste ready:
use 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::top_module(); $modp; $modp = $modp->next) {
my $name = $modp->name;
my $index = $modp->module_index;
my $ap_api_major_version = $modp->ap_api_major_version;
my $ap_api_minor_version = $modp->ap_api_minor_version;
my $commands = $modp->cmds;
}
# find a specific module
my $module = Apache2::Module::find_linked_module('mod_ssl.c');
# remove a specific module
$module->remove_loaded_module();
# access module configuration from a directive
sub MyDirective {
my ($self, $parms, $args) = @_;
my $srv_cfg = Apache2::Module::get_config($self, $parms->server);
[...]
}
# test if an Apache module is loaded
if (Apache2::Module::loaded('mod_ssl.c')) {
[...]
}
# test if a Perl module is loaded
if (Apache2::Module::loaded('Apache2::Status')) {
[...]
}
πΈ Description πΈ
Apache2::Module hands you the Perl API for creating and working with Apache modules. That's the whole pitch, no notes. π
Also, go read Apache Server Configuration Customization in Perl β it's the companion piece, iykyk.
π API π
Apache2::Module gives you the following functions and/or methods, and honestly? It ate. π
β add
Adds a module's custom configuration directive to Apache.
Apache2::Module::add($package, $cmds);
- arg1:
$package( string ) β the package of the module to add - arg2:
$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.
β ap_api_major_version
Gets the httpd API version this module was built against β not the module's own version, don't get it twisted.
$major_version = $module->ap_api_major_version();
- obj:
$module(Apache2::Module object) - ret:
$major_version( integer ) - since: 2.0.00
This "methid" (typo is canon, we keep it π) is used to check that the module is compatible with this version of the server before loading it.
β ap_api_minor_version
Gets the module API minor version.
$minor_version = $module->ap_api_minor_version();
- obj:
$module(Apache2::Module object) - ret:
$minor_version( integer ) - since: 2.0.00
ap_api_minor_version() provides API feature milestones. β¨
It's not checked during module init. Nope. Not happening.
β cmds
Gets the Apache2::Command object, which describes all of the directives this module defines.
$command = $module->cmds();
- obj:
$module(Apache2::Module object) - ret:
$command(Apache2::Command object) - since: 2.0.00
β get_config
Retrieves a module's configuration. Used by configuration directives.
$cfg = Apache2::Module::get_config($class, $server, $dir_config);
$cfg = Apache2::Module::get_config($class, $server);
$cfg = $self->get_config($server, $dir_config);
$cfg = $self->get_config($server);
- obj:
$module(Apache2::Module object) - arg1:
$class( string ) β the Perl package this configuration is for - arg2:
$server(Apache2::ServerRec object) β the current server, typically$r->serveror$parms->server. - opt arg3:
$dir_config(Apache2::ConfVector object) β by default, the configuration returned is the server level one. To retrieve the per directory configuration, use$r->per_dir_configas 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.
β find_linked_module
Finds a module based on the name of the module. π
$module = Apache2::Module::find_linked_module($name);
- arg1:
$name( string ) β the name of the module ending in.c - ret:
$module(Apache2::Module object) β the module object if found,undefotherwise. - since: 2.0.00
For example:
my $module = Apache2::Module::find_linked_module('mod_ssl.c');
β loaded
Determines if a certain module is loaded.
$loaded = Apache2::Module::loaded($module);
- name:
$module( string ) β the name of the module to search for.- If
$moduleends with.c, search all the modules, statically compiled and dynamically loaded. - If
$moduleends with.so, search only the dynamically loaded modules. - If
$moduledoesn't contain a., search the loaded Perl modules (checks%INC).
- If
- 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('mod_ssl.c')) {
[...]
}
To test is this server dynamically loaded mod_perl:
if (Apache2::Module::loaded('mod_perl.so')) {
[...]
}
To test if Apache2::Status is loaded:
if (Apache2::Module::loaded('Apache2::Status')) {
[...]
}
β module_index
Gets the index to this module's structures in config vectors.
$index = $module->module_index();
- obj:
$module(Apache2::Module object) - ret:
$index( integer ) - since: 2.0.00
β name
Gets 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 mod_perl module, will return: mod_perl.c.
β next
Gets the next module in the list, and gives you undef if this is the last module in the list. (sad, but correct π₯²)
$next_module = $module->next();
- obj:
$module(Apache2::Module object) - ret:
$next_module(Apache2::Module object) - since: 2.0.00
β remove_loaded_module
Removes a module from the list of loaded modules permanently. Like, gone-gone. No takebacks. π
$module->remove_loaded_module();
- obj:
$module(Apache2::Module object) - ret: no return value
- since: 2.0.00
β top_module
Returns the first module in the module list. Super useful to start a module iteration β main character energy, first in line. π
$module = Apache2::Module::top_module();
- ret:
$module(Apache2::Module object) - since: 2.0.00
π¦ See Also π¦
mod_perl 2.0 documentation. Go read it, bestie, it's giving lore. π
π Copyright π
mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.
π Authors π
The mod_perl development team and numerous contributors. π«Ά Legends, all of them.
and that's the whole page, bestie!! this one's from the perl v5.42.3 era, dated 2026-08-20, and it's the libapa...:Module(3pm) manual β slay, you read a manpage, so proud. periodt. π
β¨
π¦ where this page comes from
- ubuntu stonking: libapache2-mod-perl2 2.0.13-2build3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms