This is working for me.  I do some aliasing of mod_perl directories outside
of the <perl> section for stuff that all my hosts need to share so my httpd.conf
is not all perl, but I do have some aliasing going on.

    There's some stuff there to pull my records out of a database but basically
the $Company hash_ref is for each company I host.


<Perl>
use Asql::utility;
use Apache::PerlSections();
my $statement = "select ID,Company,webhost,rootdir,master_user,domain,rt from
Companies where webhost is not  NULL and master_user is not NULL";
my $dbh = connect_system_db();
my $sth = $dbh->prepare($statement)|| die "$DBI::errstr\n";
$sth->execute()|| die "$DBI::errstr\n";
my $counter = 0;

while ($Company = $sth->fetchrow_hashref()){

        $$Company{ServerAdmin} = "$$Company{master_user}\@"."$$Company{domain}";
        my $statement = "select Domain from domains where CompanyID=?";
        my $sth2 = $dbh->prepare($statement)|| die "$DBI::errstr\n";
        $sth2->execute($$Company{ID})|| die "$DBI::errstr\n";
        my $othersites = $sth2->fetchall_arrayref;
        @$othersites = map {$_="www.$_";} @$othersites;
        #build the hosts

                $VirtualHost{'192.168.0.50:80'}[$counter] = {
                     SSLDisable   => '',
                     ServerName   => "$$Company{webhost}",
                     DocumentRoot => "$$Company{rootdir}/public_html",
                     ErrorLog     => "$$Company{rootdir}/log/error.log",
                     CustomLog  => "$$Company{rootdir}/log/access.log combined",
                     ServerAdmin  => "$$Company{ServerAdmin}",
                     CheckSpelling => 'on',
                     "ErrorDocument 404" => "/errors/404.shtml",
                     Alias => ["/webrt" => "/var/burgettsys/rt/lib/images"],
                     ScriptAlias => ["/rt" => "$$Company{rootdir}/rt/bin/cgi/"],
                     ServerAlias => $othersites,
                };
        $counter++;
};

#print STDERR Apache::PerlSections->dump();
__END__

</Perl>



Dave Baker wrote:

> > Has anyone successfully built a fully perl conf file with multiple virtual
> > hosts on the same IP?  I'm giving it my best, but just can't quite get it to
> > work.  I'm stuck on aliases.  The Eagle book and the mod_perl guide have
> > both been of great help getting this far, but I can't find an example of
> > setting anything where "Directive is Repeated Multiple Times" (which may be
> > an indication that it just don't work).
>
> Not a direct answer, but an alternative to fighting with the data
> structure is just just plug a programmatic $PerlConfig .= $string and
> build the VirtualHosts as if they were plain text.
>
> Not as elegant as doing this the hard way, but it's also easier to
> explain if you have to hand the config file off to someone who knows
> Apache but not Perl.
>
> Dave
>
> --
>
> -  Dave Baker  :  [EMAIL PROTECTED]  :  [EMAIL PROTECTED]  :  http://dsb3.com/
> GnuPG: 1024D/D7BCA55D / 09CD D148 57DE 711E 6708  B772 0DD4 51D5 D7BC A55D
>
>   ------------------------------------------------------------------------
>    Part 1.2Type: application/pgp-signature

--
Wade Burgett
Burgett Systems
http://www.burgettsys.com/
[EMAIL PROTECTED]



Reply via email to