App::I...Apache(3pm)
โจ NAME โจ
App::Info::HTTPD::Apache โ Information about Apache web server
๐ฆ SYNOPSIS ๐ฆ
use App::Info::HTTPD::Apache;
my $apache = App::Info::HTTPD::Apache->new;
if ($apache->installed) {
print "App name: ", $apache->name, "\n";
print "Version: ", $apache->version, "\n";
print "Bin dir: ", $apache->bin_dir, "\n";
} else {
print "Apache is not installed. :-(\n";
}
๐ธ DESCRIPTION ๐ธ
So App::Info::HTTPD::Apache is the module that goes and finds out everything about the Apache web server living on your local system. It implements all of the methods that App::Info::HTTPD defines, so it's fully that girl. ๐
Here's the tea on events though: methods that trigger events will only trigger them the first time they're called. (Peep App::Info for the docs on handling events, iykyk.) And if you wanna start fresh โ like, say, somebody just installed Apache and you need the new scoop โ you gotta construct a brand new App::Info::HTTPD::Apache object so it can aggregate new meta data. No recycling, bestie. ๐
Some of the methods trigger the same events, and that's just because of cross-calling between methods, or because they share functions in common. But here's the thing: any one event should be triggered no more than once. Example time! The info event "Executing httpd -v" is documented for the methods name(), version(), major_version(), minor_version(), and patch_version() โ and rest assured, it will only be triggered once, by whichever of those four methods gets called first. Obsessed with the efficiency honestly. โจ
๐ INTERFACE ๐
๐ Constructor
new
my $apache = App::Info::HTTPD::Apache->new(@params);
Returns an App::Info::HTTPD::Apache object. Want the full rundown on argument parameters? Go look at App::Info. It's all there. ๐
When you call it, new() goes searching through the directories that search_bin_dirs() hands back, looking for an executable with a name that search_exe_names() hands back. If it finds one, that executable (from here on out we're calling it httpd, no matter what it was actually named when we found it) gets called by the object methods below to gather up all the data each one needs. And if httpd cannot be found? Then Apache is assumed to not be installed, and every single one of the object methods will return undef. ๐
On top of the parameters that the parent classes support โ that's App::Info and App::Info::HTTPD โ this class' new() method also supports these:
search_conf_namesโ an array reference of possible names for Apache configuration files. These get returned by thesearch_conf_names()method before the default names, and may be used byconf_file()to search for the configuration file.search_conf_dirsโ an array reference of possible directories to search for Apache configuration files in. These get returned by thesearch_conf_dirs()method before the default directories, and may be used byconf_file()to search for the configuration file.
And then there's these parameters, for when you wanna specify alternate names for the Apache executables โ you know, other than httpd, which you specify via the search_exe_names parameter:
search_ab_namessearch_apachectl_namessearch_apxs_namessearch_htdigest_namessearch_htpasswd_namessearch_logresolve_namessearch_rotatelogs_names
Events:
- info โ Looking for Apache executable
- confirm โ Path to your httpd executable?
- unknown โ Path to your httpd executable?
โญ Class Method
key_name
my $key_name = App::Info::HTTPD::Apache->key_name;
Returns the unique key name that describes this class. And what string does it hand you? The string "Apache". That's it, that's the whole vibe. ๐
๐ Object Methods
installed
print "apache is ", ($apache->installed ? '' : 'not '),
"installed.\n";
Returns true if Apache is installed, and false if it is not. How does App::Info::HTTPD::Apache figure out whether Apache is installed? It goes off the presence or absence of the httpd application on the file system, exactly as it was found back when new() constructed the object. And if Apache doesn't appear to be installed, then all of the other object methods will return empty values. Sorry bestie. ๐
name
my $name = $apache->name;
Returns the name of the application. App::Info::HTTPD::Apache parses the name right out of the system call `httpd -v`. ๐
Events:
- info โ Executing
`httpd -v` - error
- Failed to find Apache version data with
`httpd -v` - Failed to parse Apache name and version from string
- Failed to find Apache version data with
- unknown โ Enter a valid Apache name
version
my $version = $apache->version;
Returns the apache version number. App::Info::HTTPD::Apache parses the version number out of the system call `httpd -v`. โจ
Events:
- info โ Executing
`httpd -v` - error
- Failed to find Apache version data with
`httpd -v` - Failed to parse Apache name and version from string
- Failed to find Apache version data with
- unknown โ Enter a valid Apache version number
major_version
my $major_version = $apache->major_version;
Returns the Apache major version number. App::Info::HTTPD::Apache parses the version number from the system call `httpd --v`. For example, if version() returns 1.3.24, then this method returns 1. Math is math, bestie. ๐
Events:
- info โ Executing
`httpd -v` - error
- Failed to find Apache version data with
`httpd -v` - Failed to parse Apache name and version from string
- Failed to find Apache version data with
- unknown โ Enter a valid Apache major version number
minor_version
my $minor_version = $apache->minor_version;
Returns the Apache minor version number. App::Info::HTTPD::Apache parses the version number from the system call `httpd --v`. For example, if version() returns 1.3.24, then this method returns 3. And if you want the full list of possible errors, go peek at the version method. ๐ฆ
Events:
- info โ Executing
`httpd -v` - error
- Failed to find Apache version data with
`httpd -v` - Failed to parse Apache name and version from string
- Failed to find Apache version data with
- unknown โ Enter a valid Apache minor version number
patch_version
my $patch_version = $apache->patch_version;
Returns the Apache patch version number. App::Info::HTTPD::Apache parses the version number from the system call `httpd --v`. For example, if version() returns 1.3.24, then this method returns 24. See how that works? Chef's kiss. ๐ญ
Events:
- info โ Executing
`httpd -v` - error
- Failed to find Apache version data with
`httpd -v` - Failed to parse Apache name and version from string
- Failed to find Apache version data with
- unknown โ Enter a valid Apache patch version number
httpd_root
my $httpd_root = $apache->httpd_root;
Returns the HTTPD root directory path. This path is defined at compile time, and App::Info::HTTPD::Apache parses it out of the system call `httpd -V`. ๐
Events:
- info โ Executing
`httpd -V` - error
- Unable to extract compile settings from
`httpd -V` - Cannot parse HTTPD root from
`httpd -V`
- Unable to extract compile settings from
- unknown โ Enter a valid HTTPD root
magic_number
my $magic_number = $apache->magic_number;
Returns the "Magic Number" for the Apache installation. This number is also defined at compile time, and App::Info::HTTPD::Apache parses it from the system call `httpd -V`. Magic number, literally. โจ๐ฎ
Events:
- info โ Executing
`httpd -V` - error
- Unable to extract compile settings from
`httpd -V` - Cannot parse HTTPD root from
`httpd -V`
- Unable to extract compile settings from
- unknown โ Enter a valid magic number
compile_option
my $compile_option = $apache->compile_option($option);
Returns the value of the Apache compile option $option. The compile option gets looked up case-insensitively. All of the Apache compile options get collected from the system call `httpd -V`.
For compile options that contain a corresponding value (things like SUEXEC_BIN or DEFAULT_PIDLOG), compile_option() returns the value of the option if the option exists. For other options, it returns true (1) if the option was included, and false (undef) if it was not. And it returns undef if Apache isn't installed, or if the option couldn't be parsed. Want the list of possible errors? Go check the httpd_root method. ๐
Wanna learn about all the possible compile options? The Apache documentation lives at http://httpd.apache.org/docs-project/.
Events:
- info โ Executing
`httpd -V` - error
- Unable to extract compile settings from
`httpd -V` - Cannot parse HTTPD root from
`httpd -V`
- Unable to extract compile settings from
- unknown โ Enter a valid option
conf_file
Returns the full path to the Apache configuration file. So how does conf_file() find it? It looks in a bunch of locations and under a bunch of names, in this exact order:
- First it tries to use the file specified by the
SERVER_CONFIG_FILEcompile option (as returned by a call tocompile_option()) โ and if it's a relative file name, it gets appended to the directory returned byhttpd_root(). - If that file isn't found,
conf_file()then looks for a file with one of the names returned bysearch_conf_names()in theconfsubdirectory of the HTTPD root directory. - Failing that, it searches for them in each of the directories returned by
search_conf_dirs()until it finds a match.
Events:
- info โ Searching for Apache configuration file
- error โ No Apache config file found
- unknown โ Location of httpd.conf file?
user
my $user = $apache->user;
Returns the name of the Apache user. This value gets collected from the Apache configuration file as returned by conf_file(). ๐ธ
Events:
- info
- Searching for Apache configuration file
- Executing
`httpd -V` - Parsing Apache configuration file
- error
- No Apache config file found
- Cannot parse user from file
- Cannot parse group from file
- Cannot parse port from file
- Cannot parse DocumentRoot from file
- unknown
- Location of httpd.conf file?
- Enter Apache user name
group
Returns the name of the Apache user group. This value gets collected from the Apache configuration file as returned by conf_file(). ๐ซถ
Events:
- info
- Searching for Apache configuration file
- Executing
`httpd -V` - Parsing Apache configuration file
- error
- No Apache config file found
- Cannot parse user from file
- Cannot parse group from file
- Cannot parse port from file
- Cannot parse DocumentRoot from file
- unknown
- Location of httpd.conf file?
- Enter Apache user group name
port
Returns the port number on which Apache listens. This value gets collected from the Apache configuration file as returned by conf_file(). ๐ฅ
Events:
- info
- Searching for Apache configuration file
- Executing
`httpd -V` - Parsing Apache configuration file
- error
- No Apache config file found
- Cannot parse user from file
- Cannot parse group from file
- Cannot parse port from file
- Cannot parse DocumentRoot from file
- unknown
- Location of httpd.conf file?
- Enter Apache TCP/IP port number
doc_root</p>
Returns the local physical path where web pages are stored. ๐ This value gets collected from the Apache configuration file that conf_file() hands back.
Events:
- info
- Searching for Apache configuration file
- Executing
httpd -V - Parsing Apache configuration file
- error
- No Apache config file found
- Cannot parse user from file
- Cannot parse group from file
- Cannot parse port from file
- Cannot parse DocumentRoot from file
- unknown
- Location of
httpd.conffile? - Enter DocumentRoot actual directory
- Location of
cgibin_virtual</p>
Returns the virtual path where cgi-bin programs live. ๐ Also collected from the Apache configuration file returned by conf_file().
Events:
- info
- Searching for Apache configuration file
- Executing
httpd -V - Parsing Apache configuration file
- error
- No Apache config file found
- Cannot parse user from file
- Cannot parse group from file
- Cannot parse port from file
- Cannot parse ScriptAlias from file
- unknown
- Location of
httpd.conffile? - Enter ScriptAlias virtual directory
- Location of
cgibin_physical</p>
Returns the physical path where cgi-bin programs live. ๐
Yep, also collected from the Apache configuration file returned by conf_file().
Events:
- info
- Searching for Apache configuration file
- Executing
httpd -V - Parsing Apache configuration file
- error
- No Apache config file found
- Cannot parse user from file
- Cannot parse group from file
- Cannot parse port from file
- Cannot parse ScriptAlias from file
- unknown
- Location of
httpd.conffile? - Enter ScriptAlias physical directory
- Location of
executable</p>
my $executable = $apache->executable;
Returns the path to the Apache executable โ whichever of the names from search_exe_names() it actually turns out to be. โญ Heads up bestie: the executable gets searched for back in new(), so there are no events for this method. It already did its thing.
httpd</p>
my $httpd = $apache->httpd;
An alias for executable(). Same energy, different name. ๐
bin_dir</p>
my $bin_dir = $apache->bin_dir;
Returns the SQLite binary directory path. ๐ (yes, it literally says SQLite โ that's what the docs say, don't come for me). App::Info::HTTPD::Apache simply retrieves it as the directory part of the path to the HTTPD executable.
inc_dir</p>
my $inc_dir = $apache->inc_dir;
Returns the Apache include directory path. App::Info::HTTPD::Apache simply looks for the include or inc directory under the httpd_root directory, as returned by httpd_root(). ๐ฆ
Events:
- info
- Executing
httpd -V - Searching for include directory
- Executing
- error
- Unable to extract compile settings from
httpd -V - Cannot parse HTTPD root from
httpd -V - Cannot find include directory
- Unable to extract compile settings from
- unknown
- Enter a valid HTTPD root
- Enter a valid Apache include directory
lib_dir</p>
my $lib_dir = $apache->lib_dir;
Returns the Apache library directory path. App::Info::HTTPD::Apache simply looks for the lib, modules, or libexec directory under the HTTPD root directory, as returned by httpd_root(). ๐
Events:
- info
- Executing
httpd -V - Searching for library directory
- Executing
- error
- Unable to extract compile settings from
httpd -V - Cannot parse HTTPD root from
httpd -V - Cannot find library directory
- Unable to extract compile settings from
- unknown
- Enter a valid HTTPD root
- Enter a valid Apache library directory
so_lib_dir</p>
my $so_lib_dir = $apache->so_lib_dir;
Returns the Apache shared object library directory path. Currently this directory is assumed to be the same as the lib directory, so this method is simply an alias for lib_dir. ๐ซถ
Events:
- info
- Executing
httpd -V - Searching for library directory
- Executing
- error
- Unable to extract compile settings from
httpd -V - Cannot parse HTTPD root from
httpd -V - Cannot find library directory
- Unable to extract compile settings from
- unknown
- Enter a valid HTTPD root
- Enter a valid Apache library directory
static_mods</p>
Returns a list (in an array context) or an anonymous array (in a scalar context) of all the modules statically compiled into Apache. ๐ These are collected from the system call `httpd -l`. If Apache is not installed, static_mods() returns an empty list in an array context or an empty anonymous array in a scalar context.
Events:
- info
- Executing
httpd -l
- Executing
- error
- Unable to extract needed data from
httpd -l
- Unable to extract needed data from
shared_mods</p>
Returns a list (in an array context) or an anonymous array (in a scalar context) of all the shared modules compiled for Apache. These are collected by searching for all files ending in .so in the directory returned from the system call `apxs -q LIBEXECDIR`. ๐ If Apache is not installed, shared_mods() returns an empty list in an array context or an empty anonymous array in a scalar context.
Events:
- info
- Looking for
apxs - Executing
apxs -q LIBEXECDIR
- Looking for
- error
- Unable to extract module directory name from
apxs -q LIBEXECDIR
- Unable to extract module directory name from
mod_so</p>
Boolean method that returns true when mod_so has been compiled into Apache, and false if it has not. โ
โ The presence or absence of mod_so is determined by the system call `httpd -l`.
Events:
- info
- Executing
httpd -l
- Executing
- error
- Unable to extract needed data from
httpd -l
- Unable to extract needed data from
mod_perl</p>
Boolean method that returns true when mod_perl has been statically compiled into Apache, and false if it has not. The presence or absence of mod_perl is determined by the system call `httpd -l` or, for a dynamic mod_perl, by the contents of the directory returned by the system call `apxs -q LIBEXECDIR`. ๐
Events:
- info
- Executing
httpd -l - Looking for
apxs - Executing
apxs -q LIBEXECDIR
- Executing
- error
- Unable to extract needed data from
httpd -l
- Unable to extract needed data from
home_url</p>
my $home_url = $apache->home_url;
Returns the Apache home page URL. ๐ก
download_url</p>
my $download_url = $apache->download_url;
Returns the Apache download URL. โฌ๏ธ
search_exe_names</p>
my @search_exe_names = $apache->search_exe_names;
Returns a list of possible names for the Apache executable; .exe is appended to each one on Win32. ๐ช By default, the names are:
httpd
httpd2
apache-perl
apache
apache2
search_bin_dirs</p>
my @search_bin_dirs = $apache->search_bin_dirs;
Returns a list of possible directories in which to search for an executable. Used by the new() constructor to find an executable to execute and collect application info. The found directory will also be returned by the bin_dir method. ๐
The list of directories by default consists of the path as defined by File::Spec->path and the value returned by Apache2::BuildConfig->new->{APXS_BINDIR} (if Apache2::BuildConfig is installed), as well as the following directories:
/usr/local/apache/bin
/usr/local/apache2/bin
/opt/apache/bin
/opt/apache2/bin
/usr/local/bin
/usr/local/sbin
/usr/bin
/usr/sbin
/bin
/etc/httpd/bin
/etc/apache/bin
/etc/apache2/bin
/home/httpd/bin
/home/apache/bin
/home/apache2/bin
/sw/bin
/sw/sbin
/web/httpd
search_lib_dirs</p>
my @search_lib_dirs = $apache->search_lib_dirs;
Returns a list of possible directories in which to search for Apache libraries. By default, it returns this list of directories, each appended to the name of the directory returned by httpd_root():
lib
modules
libexec
search_inc_dirs</p>
my @search_inc_dirs = $apache->search_inc_dirs;
Returns a list of possible directories in which to search for Apache include files. By default, it returns this list of directories, each appended to the name of the directory returned by httpd_root():
include
inc
search_conf_names</p>
my @search_conf_dirs = $apache->search_conf_dirs;
Returns a list of possible names for Apache configuration files. These will be used bye โ yes, bye ๐ โ the conf_file() method to search for Apache configuration files. By Default, the possible configuration file names are:
httpd.conf
httpd.conf.default
search_conf_dirs</p>
my @search_conf_dirs = $apache->search_conf_dirs;
Returns a list of directories in which the conf_file() method will search for Apache configuration files. ๐
/usr/share/doc/apache-perl
/etc/httpd
Other Executable Methods
These methods return the complete paths to their like-named executables. Apache comes with a fair number of them; we provide these methods to give you a path to a subset of them. ๐ง Each method, when called, checks for an executable in the directory returned by bin_dir(). The name of the executable must be one of the names returned by the corresponding search_*_names method.
The available executable methods are:
abapachectlapxshtdigesthtpasswdlogresolverotatelogs
And the corresponding search names methods are:
search_ab_namessearch_apachectl_namessearch_apxs_namessearch_htdigest_namessearch_htpasswd_namessearch_logresolve_namessearch_rotatelogs_names
Events:
- info
- Looking for executable
- confirm
- Path to executable?
- unknown
- Path to executable?
KNOWN ISSUES ๐
It's likely that a lot more can be done to collect data about Apache. The methodology for determining the lib, inc, bin, and so_lib directories in particular may be considered rather weak. ๐ญ And the Port number can be specified multiple ways (and times!) in an Apache configuration file. Patches from those who know a great deal more about interrogating Apache will be most welcome. ๐ซถ
TO DO ๐
Add method to return the names of available DSOs. These should either be parsed from the httpd.conf file or globbed from the file system.
SUPPORT ๐
This module is stored in an open GitHub repository <http://github.com/theory/app-info/>. Feel free to fork and contribute! ๐ฅ
Please file bug reports via GitHub Issues <http://github.com/theory/app-info/issues/> or by sending mail to bug-App-Info@rt.cpan.org <mailto:bug-App-Info@rt.cpan.org>.
AUTHOR ๐
David E. Wheeler <david@justatheory.com> based on code by Sam Tregar <sam@tregar.com>.
SEE ALSO โจ
App::Info documents the event handling interface. ๐
App::Info::HTTPD is the App::Info::HTTP::Apache parent class.
Apache and mod_perl_mod_perl document mod_perl.
<http://httpd.apache.org/> is the Apache web server home page. ๐
<http://perl.apache.org/> is the mod_perl home page. ๐ช
๐ COPYRIGHT AND LICENSE ๐
okay bestie, the legal bit, and honestly? it's giving generous ๐
- Copyright (c) 2002-2011, David E. Wheeler. Some Rights Reserved.
yes, Some Rights Reserved โ not all of them, the rest are yours to play with ๐ซถ
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. no cap, that's the whole deal โจ
fr fr, that's it. no weird fine print, no secret clause, no "you must sacrifice a rubber duck at midnight" nonsense. just Perl's terms, verbatim, slay ๐
and that's the whole page, bestie ๐ญ๐
you made it all the way to the end, which is main character energy fr fr. this was App::I...Apache(3pm), pulled from the perl v5.36.0 docs, dated 2022-12-06 โ go forth and configure your Apache app like the icon you are ๐ธ๐ฆ๐
๐ฆ where this page comes from
- debian bookworm: libapp-info-perl 0.57-4 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libapp-info-perl 0.57-4 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libapp-info-perl 0.57-4 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libapp-info-perl 0.57-4 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libapp-info-perl 0.57-4 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms