The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

perl script in httpd

Discussion in 'General Discussion' started by upsforum, May 28, 2010.

  1. upsforum

    upsforum Well-Known Member

    Joined:
    Jul 27, 2005
    Messages:
    446
    Likes Received:
    0
    Trophy Points:
    16
    Hi All,

    I need of use a script perl in httpd.conf for set dynamic vhosts and I try this script but don't work, I don't know perl script

    PHP:

    <perl>
    #!/usr/bin/perl -w
    local ($ip,$host,$admin,$vroot,$aliases);
    local ($directive,$args);
    open (FILE,"/var/www/vhosts/myuser/conf/vhost-perl.conf");
    while (<
    FILE>) {
            
    next if /^\s*(#|$) / ;
            
    if (/^d+/) {
            (
    $ip,$host,$admin,$vroot,$aliases)=split /\s*,\s*/, $_;
               
    $VirtualHost{ip}= {
                       
    ServerName =>$host,
                       
    ServerAdmin => $admin,
                       
    DocumentRoot => "/var/www/vhosts/myuser/subdomains/beta/httpdocs",
                       
    ErrorLog => "logs/".$host."_error.log",
                       
    TransferLog =>"logs/".$host."_access.log"
                    
    };
                    
    $VirtualHost {$ip} {ServerAlias} =$aliases if $aliases;
                    
    $VirtualHost {$ip} {Port} =$if ($ip=~/:(\d+)$/);
            } 
    elsif ($ip) {
                    (
    $directive,$args)=split / /, $_,2;
                    
    $VirtualHost {$ip} {$directive}=$args;
            }
    }
    close (FILE);
    #_END_
    </perl>
     
Loading...

Share This Page