ispCP - Board - Support
[HowTo] Make awstats for subdomain(s) - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega Contributions Area (/forum-40.html)
+--- Forum: Howtos (/forum-41.html)
+--- Thread: [HowTo] Make awstats for subdomain(s) (/thread-9215.html)

Pages: 1 2


[HowTo] Make awstats for subdomain(s) - miklosandras - 01-15-2010 05:07 AM

Version 1.0

HowTo make awstats for subdomains:

1. create a new file: /root/mysql.cnf

PHP Code:
[client]
user=root
password
="your_root_password" 

2. create a new file: /var/www/ispcp/engine/awstats/awstats_configfile_generator

PHP Code:
#!/bin/bash
#
# Generate awstats config files for new subdomains
#
# !!!! Edit path to mysql cnf file !!!!
mycnf=/root/mysql.cnf

for subdomain_id in `echo "SELECT subdomain_id FROM ispcp.subdomain ORDER BY subdomain_name ASC" | mysql --defaults-file=$mycnf -s`;
do
domain_id=`echo "SELECT domain_id FROM ispcp.subdomain WHERE subdomain_id='$subdomain_id'" | mysql --defaults-file=$mycnf -s`;
subdomain_name=`echo "SELECT subdomain_name FROM ispcp.subdomain WHERE subdomain_id='$subdomain_id'" | mysql --defaults-file=$mycnf -s`;
domain_name=`echo "SELECT domain_name FROM ispcp.domain WHERE domain_id='$domain_id'" | mysql --defaults-file=$mycnf -s`;

if [ -
/etc/awstats/awstats.$subdomain_name.$domain_name.conf ]

then

echo " ";
echo 
"===========================================================";
echo 
"/etc/awstats/awstats.$subdomain_name.$domain_name.conf exist";
echo 
"===========================================================";
echo 
" ";

else

echo 
" ";
echo 
"===========================================================";
echo 
"/etc/awstats/awstats.$subdomain_name.$domain_name.conf not exist";
echo 
"===========================================================";
echo 
" ";
echo 
"=====================  Creating...  =======================";

echo 
" ";
echo 
"cp -p /etc/awstats/awstats.$domain_name.conf /etc/awstats/awstats.$subdomain_name.$domain_name.txt";
cp -/etc/awstats/awstats.$domain_name.conf /etc/awstats/awstats.$subdomain_name.$domain_name.txt
echo "sed -e "s/$domain_name/$subdomain_name.$domain_name/g" /etc/awstats/awstats.$subdomain_name.$domain_name.txt > /etc/awstats/awstats.$subdomain_name.$domain_name.conf";
sed -"s/$domain_name/$subdomain_name.$domain_name/g" /etc/awstats/awstats.$subdomain_name.$domain_name.txt > /etc/awstats/awstats.$subdomain_name.$domain_name.conf
echo "rm /etc/awstats/awstats.$subdomain_name.$domain_name.txt";
rm /etc/awstats/awstats.$subdomain_name.$domain_name.txt
echo " ";

echo 
"========================  Done  ===========================";
echo 
" ";

fi

done 

3. Make permission to run:

PHP Code:
chmod +/var/www/ispcp/engine/awstats/awstats_configfile_generator 

4. Add this new file to ispcp crontab: /etc/cron.d/ispcp

find this line: 25

PHP Code:
# AWStats
15      */6     *       *       *       root /var/www/ispcp/engine/awstats/awstats_updateall.pl now -awstatsprog=/usr/lib/cgi-bin/awstats.pl >/dev/null 2>&

and change to:

PHP Code:
# AWStats
15      */6     *       *       *       root /var/www/ispcp/engine/awstats/awstats_updateall.pl now -awstatsprog=/usr/lib/cgi-bin/awstats.pl >/dev/null 2>&1
45      
*/6     *       *       *       root /var/www/ispcp/engine/awstats/awstats_configfile_generator >/dev/null 2>&

5. modify this file: /etc/ispcp/apache/parts/sub_entry.tpl

find this line: 8

PHP Code:
<IfModule suexec_module>
           
SuexecUserGroup {SUEXEC_USER} {SUEXEC_GROUP}
    </
IfModule

and change to:
PHP Code:
ProxyRequests Off

   
<Proxy *>
      
Order deny,allow
      Allow from all
   
</Proxy>

   
ProxyPass                    /stats  http://localhost/stats/{SUB_NAME}
   
ProxyPassReverse             /stats  http://localhost/stats/{SUB_NAME}

    
<Location /stats>
        <
IfModule mod_rewrite.c>
            
RewriteEngine on
            RewriteRule 
^(.+)\?config=([^\?\&]+)(.*) $1\?config={SUB_NAME}&$[NC,L]
        </
IfModule>
        
AuthType Basic
        AuthName 
"Statistics for subdomain {SUB_NAME}"
        
AuthUserFile {WWW_DIR}/{DMN_NAME}/.htpasswd
        AuthGroupFile 
{WWW_DIR}/{DMN_NAME}/.htgroup
        
Require group statistics statistics_{SUB_NAME}
    </
Location>

    <
IfModule suexec_module>
           
SuexecUserGroup {SUEXEC_USER} {SUEXEC_GROUP}
    </
IfModule

6. Restart the apache.

PHP Code:
/etc/init.d/apache2 restart 

7. Regenerate config files

http://www.isp-control.net/documentation/doku.php?id=howto:ispcp:regenerate_config

8. First time, run these files:

PHP Code:
/var/www/ispcp/engine/awstats/awstats_configfile_generator
/var/www/ispcp/engine/awstats/awstats_updateall.pl now -awstatsprog=/usr/lib/cgi-bin/awstats.pl 



You can easily access your subdomain stats at http://subdomain.domain.ltd/stats
Login and Password is the same as your domain stats page.

Have fun! Smile


RE: [HowTo] Make awstats for subdomain(s) - ZooL - 01-15-2010 01:53 PM

nice, Thank you for this Howto Wink


RE: [HowTo] Make awstats for subdomain(s) - Commifreak - 01-27-2010 04:46 AM

Workzz GREAT!!111oneoneeleveneleven

I've found 2 errors on your Tutorial.

You wrote to restarting apache:

PHP Code:
/etc/init.d/apache restart 

but the correct path is

PHP Code:
/etc/init.d/apache2 restart 

Ok, everybody should know this..

But i found a second error: see your mysql.cnf:

PHP Code:
[client]
user=root
password
=your_root_password 

right syntax is:

PHP Code:
[client]
user=root
password
="your_root_password" 
I'am using # and ! in my password, which doesnt work without ".

Thanks for the Tutorial!


RE: [HowTo] Make awstats for subdomain(s) - miklosandras - 01-27-2010 05:37 AM

Thanks for your fixes Smile updated.


RE: [HowTo] Make awstats for subdomain(s) - Commifreak - 01-27-2010 05:39 AM

(01-27-2010 05:37 AM)miklosandras Wrote:  Thanks for your fixes Smile updated.

Version 1.0?

Big Grin


RE: [HowTo] Make awstats for subdomain(s) - sidha - 03-30-2010 03:23 AM

Thanks!
My only problem: 403 forbidden:
Forbidden. You don't have permission to access /stats/mydomain.com/ on this server.
How can i correct this error?


RE: [HowTo] Make awstats for subdomain(s) - cam - 11-19-2010 10:48 AM

@sidha

Did you ever figure this out? If so please share.


RE: [HowTo] Make awstats for subdomain(s) - seoforu - 11-20-2010 06:36 PM

This logfile analyzer documentation would be very useful in keeping the records.


RE: [HowTo] Make awstats for subdomain(s) - nortol - 04-16-2011 09:05 AM

we need this solution in the next generation of ispcp...


RE: [HowTo] Make awstats for subdomain(s) - ricardon21 - 04-20-2011 12:21 AM

Great news update!! I am wondering how you guys manage to find such kind of information so early. Certainly helpful for me and other readers also as I am finding so many good comments here.
graham Texas