Re: mod_perl and vhost configs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




>It looks like "$include" is getting the value "Include" without aninclude file name.
>The reason is very simple. You forgot to declare
>$include as local.

You're not kidding! It is very temperamental.

I resolved the issues, and this portion appears to be working well. I'll attach the result below.

I am trying to revamp our architecture to be more svn oriented. The new setup is an EVA4400 served
up via NFS with a few Polyserve boxes.

I have machines for predev, dev, staging, and production (several of course).

The idea is to isolate any non-site specific configs and have one standard base set, hence the mod_perl effort.

At some point I'll get to putting in place some more stuff, like promoting sites between the environments without
hassle, perhaps even hand that responsibility off to some extent to development (eg; dev->stage).

Thanks for making me see it wasn't _just_ perl though. I was under the impression that mod_perl kept the scripts
contained and simple used the resulting output. More like piping I guess.

Here's that code, which simple propagates vhost configs based on the presence of a site config file, and thanks again.


<Perl>
    use Sys::Hostname;
    use File::Basename;
    use Apache2::ServerUtil;
    my $s = Apache2::ServerUtil->server;
    $s->add_config(['NameVirtualHost *:80']);

##################################################
# Get site/configuration environment using hostname()
# eg; predev01 = predev, prod01 = prod, prod02 = prod
#
    my $env=hostname();
    $env=~s/^(.*)\d+\d+\..*$/$1/;

##################################################
# Where's cronolog?
#
    my $cronolog="/efs/www/$env/app/cronolog/1.6.2/sbin/cronolog";

##################################################
# Go through the environments "CONF" directory
# to find out what sites we should load.
#
    my @configs=`find /efs/www/$env/conf/ -type f`;
    foreach $cf (@configs){
        my ($sn,$inc,$dr);
        chomp $cf;
        $inc=$cf;
        $cf = basename($cf);
        $sn=$env . "\." . $cf;
        $dr="/efs/www/$env/sites/$cf/";
        unless (-e $dr){mkdir($dr);}
      
##################################################
# This is the actual Apache Virt Configuration.
# Standard BASE configs are here, site details
# are in the $site_conf file.
#
        $s->add_config( ["<VirtualHost *:80>",
                                "ServerName $sn",
                                "ServerAdmin peterm\@nypl.org",
                                "DocumentRoot \"$dr\"",
                                "Include \"$inc\"",
                                "ErrorLog \"|$cronolog /var/apache/logs/error/$cf/%Y-%m-%d.error.log\"",
                                "CustomLog \"|$cronolog /var/apache/logs/access/$cf/%Y-%m-%d.access.log\" combinedio",
                                "</VirtualHost>"
                        ]);
        }
</Perl>



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux