Current time: 05-03-2024, 05:04 PM Hello There, Guest! (LoginRegister)


Post Reply 
[HowTo] Make awstats for subdomain(s)
Author Message
miklosandras Offline
Junior Member
*

Posts: 27
Joined: Dec 2008
Reputation: 0
Post: #1
[HowTo] Make awstats for subdomain(s)
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...ate_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
(This post was last modified: 08-28-2012 06:32 PM by miklosandras.)
01-15-2010 05:07 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


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

Forum Jump:


User(s) browsing this thread: 1 Guest(s)