App-Info
view release on metacpan or search on metacpan
lib/App/Info/HTTPD/Apache.pm view on Meta::CPAN
=over 4
=item search_conf_names
An array reference of possible names for Apache configuration files. These
will be returned by the C<search_conf_names()> method before the default
names, and may be used by C<conf_file()> to search for the configuration file.
=item search_conf_dirs
An array reference of possible directories in which to search for Apache
configuration files. These will be returned by the C<search_conf_dirs()>
method before the default directories, and may be used by C<conf_file()> to
search for the configuration file.
=back
As well as these parameters to specify alternate names for Apache executables
(other than F<httpd>, which you specify via the C<search_exe_names> parameter):
=over
=item search_ab_names
=item search_apachectl_names
=item search_apxs_names
=item search_htdigest_names
=item search_htpasswd_names
=item search_logresolve_names
=item search_rotatelogs_names
=back
B<Events:>
=over 4
=item info
Looking for Apache executable
=item confirm
Path to your httpd executable?
=item unknown
Path to your httpd executable?
=back
=cut
sub new {
# Construct the object.
my $self = shift->SUPER::new(@_);
for my $exe (qw(search_conf_dirs search_conf_names),
map { "search_$_\_names" } @EXES
) {
if (exists $self->{$exe}) {
$self->{$exe} = [$self->{$exe}] unless ref $self->{$exe} eq 'ARRAY';
} else {
$self->{$exe} = [];
}
}
# Find Apache executable.
$self->info("Looking for Apache executable");
my @paths = $self->search_bin_dirs;
my @exes = $self->search_exe_names;
if (my $exe = $u->first_cat_exe(\@exes, @paths)) {
# We found httpd. Confirm.
$self->{executable} = $self->confirm(
key => 'path to httpd',
prompt => 'Path to your httpd executable?',
value => $exe,
callback => sub { -x },
error => 'Not an executable',
);
} else {
# Handle an unknown value.
$self->{executable} = $self->unknown(
key => 'path to httpd',
prompt => 'Path to your httpd executable?',
callback => sub { -x },
error => 'Not an executable',
);
}
return $self;
};
##############################################################################
=head2 Class Method
=head3 key_name
my $key_name = App::Info::HTTPD::Apache->key_name;
Returns the unique key name that describes this class. The value returned is
the string "Apache".
=cut
sub key_name { 'Apache' }
##############################################################################
=head2 Object Methods
=head3 installed
print "apache is ", ($apache->installed ? '' : 'not '),
lib/App/Info/HTTPD/Apache.pm view on Meta::CPAN
return unless $self->{executable};
$get_static_mods->($self) unless exists $self->{static_mods};
$get_shared_mods->($self)
unless $self->{mod_perl} || exists $self->{so_mods};
return $self->{mod_perl};
}
##############################################################################
=head3 home_url
my $home_url = $apache->home_url;
Returns the Apache home page URL.
=cut
sub home_url { "http://httpd.apache.org/" }
##############################################################################
=head3 download_url
my $download_url = $apache->download_url;
Returns the Apache download URL.
=cut
sub download_url { "http://www.apache.org/dist/httpd/" }
##############################################################################
=head3 search_exe_names
my @search_exe_names = $apache->search_exe_names;
Returns a list of possible names for the Apache executable; F<.exe> is
appended to each on Win32. By default, the names are:
=over
=item httpd
=item httpd2
=item apache-perl
=item apache
=item apache2
=back
=cut
sub search_exe_names {
my $self = shift;
my @exes = qw(httpd httpd2 apache-perl apache apache2);
if (WIN32) { $_ .= ".exe" for @exes }
return ( $self->SUPER::search_exe_names, @exes );
}
##############################################################################
=head3 search_bin_dirs
my @search_bin_dirs = $apache->search_bin_dirs;
Returns a list of possible directories in which to search an executable. Used
by the C<new()> constructor to find an executable to execute and collect
application info. The found directory will also be returned by the C<bin_dir>
method.
The list of directories by default consists of the path as defined by C<<
File::Spec->path >> and the value returned by
C<< Apache2::BuildConfig->new->{APXS_BINDIR} >> (if Apache2::BuildConfig is
installed), as well as the following directories:
=over 4
=item /usr/local/apache/bin
=item /usr/local/apache2/bin
=item /opt/apache/bin
=item /opt/apache2/bin
=item /usr/local/bin
=item /usr/local/sbin
=item /usr/bin
=item /usr/sbin
=item /bin
=item /etc/httpd/bin
=item /etc/apache/bin
=item /etc/apache2/bin
=item /home/httpd/bin
=item /home/apache/bin
=item /home/apache2/bin
=item /sw/bin
=item /sw/sbin
=item /web/httpd
=back
=cut
sub search_bin_dirs {
# See if mod_perl2 knows where Apache is installed.
eval { require Apache2::BuildConfig };
my @path = $@ ? () : Apache2::BuildConfig->new->{APXS_BINDIR};
return (
shift->SUPER::search_bin_dirs,
$u->path,
@path,
qw(
/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/apache2/bin
/home/apache/bin
/sw/bin
/sw/sbin
/web/httpd
)
);
}
##############################################################################
=head3 search_lib_dirs
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 C<httpd_root()>:
=over 4
=item lib
=item modules
=item libexec
=back
=cut
sub search_lib_dirs {
my $self = shift;
my $root = $self->httpd_root;
return (
$self->SUPER::search_lib_dirs,
( $root
? map { $u->catdir($root, $_) } qw(lib libexec modules)
: ()
),
'/usr/lib/apache/1.3',
'/usr/lib/apache/2.0',
);
}
##############################################################################
=head3 search_inc_dirs
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 C<httpd_root()>:
=over 4
=item include
=item inc
=back
=cut
sub search_inc_dirs {
my $self = shift;
my $root = $self->httpd_root;
return (
$self->SUPER::search_inc_dirs,
( $root
? map { $u->catdir($root, $_) } qw(include inc)
: ()
),
);
}
##############################################################################
=head3 search_conf_names
my @search_conf_dirs = $apache->search_conf_dirs;
Returns a list of possible names for Apache configuration files. These will be
used bye the C<conf_file()> method to search for Apache configuration files.
By Default, the possible configuration file names are:
=over 4
=item F<httpd.conf>
=item F<httpd.conf.default>
=back
=cut
sub search_conf_names {
return (
@{ shift->{search_conf_names} },
qw(httpd.conf httpd.conf.default)
);
}
##############################################################################
=head3 search_conf_dirs
my @search_conf_dirs = $apache->search_conf_dirs;
Returns a list of directories in which the C<conf_file()> method will search
for Apache configuration files.
=over 4
=item /usr/share/doc/apache-perl
=item /etc/httpd
=back
=cut
sub search_conf_dirs {
return (
@{ shift->{search_conf_dirs} },
qw(/usr/share/doc/apache-perl /etc/httpd)
);
}
( run in 0.885 second using v1.01-cache-2.11-cpan-5a3173703d6 )