NAME

Apache::Defaults - Get default settings for Apache httpd daemon

SYNOPSIS

$x = new Apache::Defaults;
print $x->name;
print $x->version;
print $x->server_root;
print $x->server_config;
print $x->built;
print $x->architecture;
print $x->MPM;
print $x->defines('DYNAMIC_MODULE_LIMIT');
print $x->preloaded('cgi_module');

DESCRIPTION

Detects the default settings of the Apache httpd daemon by invoking it with appropriate options and analyzing its output.

METHODS

new

$x = new Apache::Defaults(%attrs);

Detects the settings of the apache server and returns the object representing them. Attributes (%attrs) are:

server

Full pathname of the httpd binary to inspect. The argument can also be a reference to the list of possible pathnames. In this case, the first of them that exists on disk and has executable privileges will be used. Full command line can also be used, e.g.:

server => '/usr/sbin/httpd -d /etc/httpd'

The default used in the absense of this attribute is:

[ '/usr/sbin/apachectl', '/usr/sbin/httpd', '/usr/sbin/apache2' ]

The use of apachectl is preferred over directly invoking httpd daemon, because the apache configuration file might contain referenmces to environment variables defined elsewhere, which will cause httpd to fail. apachectl takes care of this by including the file with variable definitions prior to calling httpd. See also environ, below.

environ

Name of the shell script that sets the environment for httpd invocation. Usually, this is the same script that is sourced by apachectl prior to passing control over to httpd. This option provides another solution to the environment problem mentioned above. E.g.:

$x = new Apache::Defaults(environ => /etc/apache2/envvars)
on_error

Controls error handling. Allowed values are croak and return. If the value is croak (the default), the method will croak if an error occurs. If set to return, the constructor will return a valid object. The httpd exit status and diagnostics emitted to the stderr will be available via the status and error methods.

status

$x = new Apache::Defaults(on_error => 'return');
if ($x->status) {
    die $x->error;
}

Returns the status of the last httpd invocation (i.e. the value of the $? perl variable after waitpid). The caller should inspect this value, after constructing an Apache::Defaults object with the on_error attribute set to return.

error

Returns additional diagnostics if $x->status != 0. Normally, these are diagnostic messages that httpd printed to standard error before termination.

server

$s = $x->server;

Returns the pathname of the httpd binary.

server_command

@cmd = $x->server_command;

Returns the full command line of the httpd binary.

server_config

$s = $x->server_config;

Returns the full pathname of the server configuration file.

environ

$hashref = $x->environ;

Returns a reference to the environment used when invoking the server.

name

$s = $x->name;

Returns server implementation name (normally Apache).

version

$v = $x->version;

Returns server version (as string).

platform

$s = $x->platform;

Platform (distribution) on which the binary is compiled.

architecture

Architecture for which the server is built.

built

$d = $x->built;

Returns a DateTime object, representing the time when the server was built.

loaded_with

APR tools with which the server is loaded.

compiled_with

APR tools with which the server is compiled.

MPM

MPM module loaded in the configuration.

MPM_threaded

True if the MPM is threaded.

MPM_forked

True if the MPM is forked.

defines

@names = $x->defines;

Returns the list of symbolic names defined during the compilation. The names are in lexical order.

@values = $x->defines(@names);

Returns values of the named defines.

server_root

$s = $x->server_root;

Returns default server root directory. This is equivalent to

$x->defines('HTTPD_ROOT');

preloaded

@ids = $x->preloaded;

Returns the list of the preloaded module identifiers, in lexical order.

@sources = $x->preloaded(@ids);

Returns the list of module source names for the given source identifiers. For non-existing identifiers, undef is returned.

LICENSE

GPLv3+: GNU GPL version 3 or later, see http://gnu.org/licenses/gpl.html.

This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

AUTHORS

Sergey Poznyakoff <gray@gnu.org>