I have installed mod_perl on my server via yum to make use of Perl sections in the Apache config. I'm running Apache 2.2 on CentOS 6. I installed the necessary Perl modules (DB2 driver mainly) via cpan.
This is the script:
<Perl>
#!/usr/bin/perl
#
# @File ApacheDomainHandler.pl
# @Author Martin
# @Created 05.01.2015 16:53:45
#
use strict;
use warnings;
# use module
use XML::Simple;
use DBI;
use Apache2::ServerUtil();
use Apache::PerlSections();
my $apache = Apache2::ServerUtil->server;
my $database = 'dbi:DB2:XXXXXX';
my $user = 'XXXXXXXX';
my $password = 'XXXXXX';
my $schema = 'XXXX';
my $blogapiurl = 'http://localhost';
my $dbh = DBI->connect($database, $user, $password)
or die "Can't connect to $database: $DBI::errstr";
my $sth = $dbh->prepare(
qq{ SELECT "businessXML" from $schema."Organisations" }
)
or die "Can't prepare statement: $DBI::errstr";
my $rc = $sth->execute
or die "Can't execute statement: $DBI::errstr";
my $businessXML;
while (($businessXML) = $sth->fetchrow()) {
my $xml = XMLin($businessXML);
if($xml && $xml->{website}){
my $url = URI->new($xml->{website});
if($url->host){
my $host = $url->host;
my $orgId = $xml->{id};
my $vhost = qq{
<VirtualHost *:80>
ServerName $host
ProxyPreserveHost Off
ProxyPass /assets $blogapiurl/assets
ProxyPassReverse /assets $blogapiurl/assets
ProxyPass / $blogapiurl/user/$orgId/
ProxyPassReverse / $blogapiurl/user/$orgId/
</VirtualHost>
};
//$apache->add_config($vhost);
$apache->add_config([$vhost]);
}
}
}
# check for problems which may have terminated the fetch early
warn $DBI::errstr if $DBI::err;
$sth->finish;
$dbh->disconnect;
print STDERR Apache::PerlSections->dump( );
</Perl>
I think the server is not using the script at all. Dump doesn't give me anything in the error_log. How can I check if Apache is really using my script?