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

App::Info::HTTPD::Apache supplies information about the Apache web server installed on the local system. It implements all of the methods defined by App::Info::HTTPD. Methods that throw errors will throw them only the first time they're called. To start over (after, say, someone has installed Apache) construct a new App::Info::HTTPD::Apache object to aggregate new metadata.

CONSTRUCTOR

new

my $apache = App::Info::HTTPD::Apache->new(@params);

Returns an App::Info::HTTPD::Apache object. See App::Info for a complete description of argument parameters.

When called, new() searches the file system for the httpd, apache-perl, or apache application. If found, the application (hereafer referred to as httpd, regardless of how it was actually found to be named) will be called by the object methods below to gather the data necessary for each. If httpd cannot be found, then Apache is assumed not to be installed, and each of the object methods will return undef.

App::Info::HTTPD::Apache searches for httpd along your path, as defined by File::Spec-path>. Failing that, it searches the following directories:

/usr/local/apache/bin
/usr/local/bin
/usr/local/sbin
/usr/bin
/usr/sbin
/bin
/opt/apache/bin
/etc/httpd/bin
/etc/apache/bin
/home/httpd/bin
/home/apache/bin
/sw/bin
/sw/sbin

OBJECT METHODS

installed

print "apache is ", ($apache->installed ? '' : 'not '),
  "installed.\n";

Returns true if Apache is installed, and false if it is not. App::Info::HTTPD::Apache determines whether Apache is installed based on the presence or absence of the httpd application on the file system, as found when new() constructed the object. If Apache does not appear to be installed, then all of the other object methods will return empty values.

name

my $name = $apache->name;

Returns the name of the application. App::Info::HTTPD::Apache parses the name from the system call `httpd -v`. See the version method for a list of possible errors.

version

my $version = $apache->version;

Returns the apache version number. App::Info::HTTPD::Apache parses the version number from the system call `httpd --v`. Throws an error if Apache is installed but the version number or name could not be parsed.

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". See the version method for a list of possible errors.

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". See the version method for a list of possible errors.

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 the version method for a list of possible errors.

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 from the system call `httpd -V`. Throws an error if Apache is installed but the HTTPD root could not be parsed.

magic_number

my $magic_number = $apache->magic_number;

Returns the "Magic Number" for the Apache installation. This number is defined at compile time, and App::Info::HTTPD::Apache parses it from the system call `httpd -V` See the httpd_root method for a list of possible errors.

compile_option

my $compile_option = $apache->compile_option($option);

Returns the value of the Apache compile option $option. The compile option is looked up case-insensitively. All of the Apache compile options are collected from the system call `httpd -V`. For compile options that contain a corresponding value (such as "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. Returns undef if Apache is not installed or if the option could not be parsed. See the httpd_root method for a list of possible errors.

See the Apache documentation at http://httpd.apache.org/docs-project/ to learn about all the possible compile options.

conf_file

Returns the full path to the Apache configuration file. conf_file() looks for the configuration file in a number of locations and under a number of names. First it tries to use the file specifed by the SERVER_CONFIG_FILE compile option (as returned by a call to compile_option()) -- and if it's a relative file name, it gets appended to the directory returned by httpd_root(). If that file isn't found, conf_file() then looks for the files httpd.conf and httpd.conf.default in the conf subdirectory of the HTTPD root directory. Failing that, it looks for the following:

/usr/share/doc/apache-perl/examples/httpd.conf
/usr/share/doc/apache-perl/examples/httpd.conf.default
/etc/httpd/httpd.conf
/etc/httpd/httpd.conf.default

Throws an error and returns undef if the file cannot be found.

user

my $user = $apache->user;

Returns the name of the Apache user. This value is collected from the Apache configuration file as returned by conf_file(). Throws an error and returns undefif the configuration file cannot be found or if the user name, group, or port number could not be parsed from the configuration file.

group

Returns the name of the Apache user group. This value is collected from the Apache configuration file as returned by conf_file(). See the "user" method for a list of possible errors.

port

Returns the port number on which Apache listens. This value is collected from Apache configuration file as returned by conf_file(). See the "user" method for a list of possible errors.

bin_dir

my $bin_dir = $apache->bin_dir;

Returns the Apache binary directory path. App::Info::HTTPD::Apache simply looks for the bin directory under the HTTPD root directory, as returned by httpd_root(). Throws an error and eturns undef if Apache is not installed or if the bin directory could not be found.

inc_dir

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(). Throws an error and eturns undef if Apache is not installed or if the inc directory could not be found.

lib_dir

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(). Throws an error and returns undef if Apache is not installed or if the lib directory could not be found.

so_lib_dir

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. Throws an error and returns undef if Apache is not installed or if the lib directory could not be found.

static_mods

Returns a list (in an array context) or an anonymous array (in a scalar reference) of all of the modules statically compiled into Apache. These are collected from the system call `httpd -l`. If Apache is not installed, static_mods() throws an error and returns an empty list in an array context or an empty anonymous array in a scalar context.

mod_so

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`. See the "static_mods" method for a list of possible errors.

mod_perl

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`. See the "static_mods" method for a list of possible errors.

home_url

my $home_url = $apache->home_url;

Returns the Apache home page URL.

download_url

my $download_url = $apache->download_url;

Returns the Apache download URL.

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.

BUGS

Feel free to drop me a line if you discover any bugs. Patches welcome.

AUTHOR

David Wheeler <david@wheeler.net> based on code by Sam Tregar <sam@tregar.com>.

SEE ALSO

App::Info, App::Info::HTTPD, Apache

COPYRIGHT AND LICENSE

Copyright (c) 2002, David Wheeler. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.