>So write your perl sections as if you had "use strict;", and declare
>all your variables local using "my", unless you want to directly pass
>something to apache.
>So use:
>my $s = Apache2::ServerUtil->server;
>You need to do this each time you introduce a local variable, eg:
>my $hostname=hostname();
>otherwise you will be setting the Apache directive to your hostname.
I spent some time reorganizing the script a bit, after finding some more documentation,
I no longer have the previous issue. I will include the new structure below. The message
that I am getting is :
$parms->add_config() has failed: Include takes one argument, Name of the config
file to be included at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Apache2/PerlSections.pm line 215.\n
I am sending references to add_config, which I believe is ok.
The documentation is a bit high level view, as I have found. Is there anything more detailed, in examples or otherwise, or
is it best just to trace the mod?
Anyhow, please let me know if anything pops out in the below conf! Thanks-
<Perl>
use Sys::Hostname;
use File::Basename;
use Apache2::ServerUtil;
my $s = Apache2::ServerUtil->server;
$s->add_config(['NameVirtualHost *:80']);
##################################################
# Get site/configuration paths using
hostname()
#
my $hostname=hostname();
$hostname=~s/^(.*)\d+\d+\..*$/$1/;
##################################################
# Where's cronolog?
my $cronolog="/efs/www/$hostname/app/cronolog/1.6.2/sbin/cronolog";
##################################################
# Go through the environments "CONF" directory
# to find out what sites we should load.
#
@sites=`find /efs/www/$hostname/conf/ -type f`;
foreach $site (@sites){
$site_conf=$site;
$site_name=$hostname . "\." . basename($site);
chomp ($site_name,$site_conf);
##################################################
# This is the actual Apache Virt Configuration.
# Standard BASE configs are here, site details
# are
in the $site_conf file.
if (-e $siteconf){$include="Include $siteconf"}else{$include="";}
@vhost_conf = ( '<VirtualHost *:80>',
'ServerName ' . $site_name,
'ServerAdmin peterm\@nypl.org',
'DocumentRoot
"/efs/www/'.$hostname.'/sites/'.$sitename.'/"',
$include,
'ErrorLog "|'.$cronolog.' /var/apache/logs/error/'.$sitename.'/%Y-%m-%d.error.log"',
'CustomLog "|'.$cronolog.' /var/apache/logs/access/'.$sitename.'/%Y-%m-%d.access.log"
combinedio',
'</VirtualHost>'
);
$s->add_config(\@vhost_conf);
}
</Perl>