You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tue Topholm <tt...@device.dk> on 2006/11/15 21:22:54 UTC

add more serverAlias to vhost conf

Hi Group

I have this script

 

<Perl>

use DBI;

my ($sth, $dbh, $domain, $domainID, $created, $sql, $sqlsa);

$dbh = DBI->connect("DBI:xxxx:localhost","xxxx","xxxx");

$sth = $dbh->prepare("SELECT domainID, domain, created FROM domain ORDER BY
domainID ASC");

$sth->execute();

while (($domainID, $domain, $created) = $sth->fetchrow_array())

{

        if($created == 0)

        {

                system("/bin/mkdir /home/$domain");

                system("/bin/mkdir /home/$domain/www");

                system("/bin/mkdir /home/$domain/ErrorLog");

                system("/bin/cp /home/index.php
/home/$domain/www/index.php");

                system("/bin/chown apache:apache -R /home/$domain");

                $sql = $dbh->prepare("UPDATE domain SET created = 1 WHERE
domainID = $domainID");

                $sql->execute();

        }

        push @{ $VirtualHost{'*:80'} },

                {

                 ServerName     => "$domain",

                 ServerAdmin    => "postmaster@$domain",

                 ServerAlias    => "www.$domain",

                 DocumentRoot   => "/home/$domain/www",

                 ErrorLog       =>
"/home/$domain/ErrorLog/$domain-error_log",

                 #CustomLog     => "/websitelog/$domain combined",

                 CustomLog      => qq{"|/usr/sbin/cronolog
/websitelog/${domain}_access_log.\%Y-\%m-\%d" combined},

                };

}

$sth->finish();

$dbh->disconnect();

</Perl>

 

It works perfectly

But now I want to add some more serveraliases I have in another table, with
domainID as foreign key, which is primary in domain-table.


I know how to make the sql-string and all that, but how do I add the
serveralias to it, because I can't do it in the middle of pushing data into
the array, or can I..

 

Should I first push the data as I do now, and the push the new data
afterwards, and if so how do I do that?

 

I hope you can help

 

Med venlig hilsen / Best Regards
Tue Topholm

Device.Webbureau
M: +45 26 74 07 41

P: +45 70 21 00 04
LinkedIN: http://www.linkedin.com/in/ttopholm