App-Info
view release on metacpan or search on metacpan
lib/App/Info/HTTPD/Apache.pm view on Meta::CPAN
return $self->{magic_number};
}
##############################################################################
=head3 compile_option
my $compile_option = $apache->compile_option($option);
Returns the value of the Apache compile option C<$option>. The compile option
is looked up case-insensitively. All of the Apache compile options are
collected from the system call C<`httpd -V`>. For compile options that contain
a corresponding value (such as "SUEXEC_BIN" or "DEFAULT_PIDLOG"),
C<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(C<undef>) if it was not. Returns C<undef> if Apache is not installed or
if the option could not be parsed. See the L<httpd_root|"httpd_root"> method
for a list of possible errors.
See the Apache documentation at L<http://httpd.apache.org/docs-project/> to
learn about all the possible compile options.
B<Events:>
=over 4
=item info
Executing `httpd -V`
=item error
Unable to extract compile settings from `httpd -V`
Cannot parse HTTPD root from `httpd -V`
=item unknown
Enter a valid option
=back
=cut
sub compile_option {
my $self = shift;
return unless $self->{executable};
# Get the compile settings.
$get_compile_settings->($self) unless $self->{-V};
# Handle an unknown value.
my $option = lc $_[0];
$self->{$option} = $self->unknown( key => "apache option $option" )
unless defined $self->{$option};
return $self->{$option};
}
##############################################################################
=head3 conf_file
Returns the full path to the Apache configuration file. C<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 specified by the C<SERVER_CONFIG_FILE>
compile option (as returned by a call to C<compile_option()>) -- and if it's a
relative file name, it gets appended to the directory returned by
C<httpd_root()>. If that file isn't found, C<conf_file()> then looks for a
file with one of the names returned by C<search_conf_names()> in the F<conf>
subdirectory of the HTTPD root directory. Failing that, it searches for them
in each of the directories returned by C<search_conf_dirs()> until it finds a
match.
B<Events:>
=over 4
=item info
Searching for Apache configuration file
=item error
No Apache config file found
=item unknown
Location of httpd.conf file?
=back
=cut
sub conf_file {
my $self = shift;
return unless $self->{executable};
unless (exists $self->{conf_file}) {
$self->info("Searching for Apache configuration file");
my $root = $self->httpd_root;
my $conf = $self->compile_option('SERVER_CONFIG_FILE');
$conf = $u->file_name_is_absolute($conf) ?
$conf : $u->catfile($root, $conf) if $conf;
if ($conf && -f $conf) {
$self->{conf_file} = $conf;
} else {
# Paths to search.
my @confs = $self->search_conf_names;
$self->{conf_file} = $u->first_cat_path(\@confs, $self->search_conf_dirs)
or $self->error("No Apache config file found");
}
}
# Handle an unknown value.
$self->{conf_file} =
$self->unknown( key => 'apache conf file',
prompt => "Location of httpd.conf file?",
callback => sub { -f },
error => "Not a file")
unless defined $self->{conf_file};
return $self->{conf_file};
}
##############################################################################
=head3 user
my $user = $apache->user;
lib/App/Info/HTTPD/Apache.pm view on Meta::CPAN
$self->{cgibinp} = $self->unknown(
key => 'physical cgi-bin',
prompt => 'Enter ScriptAlias (cgi-bin) physical directory',
callback => $is_dir,
error => "Not a directory"
) unless $self->{cgibinp};
return $self->{cgibinp};
}
##############################################################################
=head3 executable
my $executable = $apache->executable;
Returns the path to the Apache executable, which will be defined by one of the
names returned by C<search_exe_names()>. The executable is searched for in
C<new()>, so there are no events for this method.
=head3 httpd
my $httpd = $apache->httpd;
An alias for C<executable()>.
=cut
sub executable { shift->{executable} }
##############################################################################
=head3 bin_dir
my $bin_dir = $apache->bin_dir;
Returns the SQLite binary directory path. App::Info::HTTPD::Apache simply
retrieves it as the directory part of the path to the HTTPD executable.
=cut
sub bin_dir {
my $self = shift;
return unless $self->{executable};
unless (exists $self->{bin_dir} ) {
my @parts = $u->splitpath($self->{executable});
$self->{bin_dir} = $u->catdir(
($parts[0] eq '' ? () : $parts[0]),
$u->splitdir($parts[1])
);
}
return $self->{bin_dir};
}
##############################################################################
=head3 inc_dir
my $inc_dir = $apache->inc_dir;
Returns the Apache include directory path. App::Info::HTTPD::Apache simply
looks for the F<include> or F<inc> directory under the F<httpd_root>
directory, as returned by C<httpd_root()>.
B<Events:>
=over 4
=item info
Executing `httpd -V`
Searching for include directory
=item error
Unable to extract compile settings from `httpd -V`
Cannot parse HTTPD root from `httpd -V`
Cannot find include directory
=item unknown
Enter a valid HTTPD root
Enter a valid Apache include directory
=back
=cut
sub inc_dir {
my $self = shift;
return unless $self->{executable};
unless (exists $self->{inc_dir}) {{
my $root = $self->httpd_root || last; # Double braces allow this.
$self->info("Searching for include directory");
$self->{inc_dir} = $u->first_dir($self->search_inc_dirs)
or $self->error("Cannot find include directory");
}}
# Handle unknown value.
$self->{inc_dir} = $self->unknown( key => 'apache inc dir',
callback => $is_dir)
unless $self->{inc_dir};
return $self->{inc_dir};
}
##############################################################################
=head3 lib_dir
my $lib_dir = $apache->lib_dir;
Returns the Apache library directory path. App::Info::HTTPD::Apache simply
looks for the F<lib>, F<modules>, or F<libexec> directory under the HTTPD
root> directory, as returned by C<httpd_root()>.
B<Events:>
=over 4
=item info
Executing `httpd -V`
Searching for library directory
=item error
Unable to extract compile settings from `httpd -V`
Cannot parse HTTPD root from `httpd -V`
Cannot find library directory
=item unknown
Enter a valid HTTPD root
Enter a valid Apache library directory
=back
=cut
sub lib_dir {
my $self = shift;
return unless $self->{executable};
unless (exists $self->{lib_dir}) {
if ($self->httpd_root) {
$self->info("Searching for library directory");
if (my $d = $u->first_dir($self->search_lib_dirs)) {
$self->{lib_dir} = $d;
} else {
$self->error("Cannot find library direcory");
}
} else {
# Handle unknown value.
$self->{lib_dir} = $self->unknown(
key => 'apache lib dir',
callback => $is_dir
);
}
}
return $self->{lib_dir};
}
##############################################################################
=head3 so_lib_dir
my $so_lib_dir = $apache->so_lib_dir;
Returns the Apache shared object library directory path. Currently, this
( run in 2.680 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )