Current time: 03-28-2020, 05:45 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
ZooL Offline
Moderator
*****
Moderators

Posts: 3,429
Joined: Jan 2007
Reputation: 79
Post: #2
RE: [HowTo] Make awstats for subdomain(s)
nice, Thank you for this Howto Wink
01-15-2010 01:53 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Commifreak Offline
Junior Member
*

Posts: 13
Joined: Dec 2009
Reputation: 0
Post: #3
RE: [HowTo] Make awstats for subdomain(s)
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!
01-27-2010 04:46 AM
Visit this user's website Find all posts by this user Quote this message in a reply
miklosandras Offline
Junior Member
*

Posts: 27
Joined: Dec 2008
Reputation: 0
Post: #4
RE: [HowTo] Make awstats for subdomain(s)
Thanks for your fixes Smile updated.
(This post was last modified: 01-27-2010 05:38 AM by miklosandras.)
01-27-2010 05:37 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Commifreak Offline
Junior Member
*

Posts: 13
Joined: Dec 2009
Reputation: 0
Post: #5
RE: [HowTo] Make awstats for subdomain(s)
(01-27-2010 05:37 AM)miklosandras Wrote:  Thanks for your fixes Smile updated.

Version 1.0?

Big Grin
01-27-2010 05:39 AM
Visit this user's website Find all posts by this user Quote this message in a reply
sidha Offline
Junior Member
*

Posts: 13
Joined: Aug 2009
Reputation: 0
Post: #6
RE: [HowTo] Make awstats for subdomain(s)
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?
03-30-2010 03:23 AM
Find all posts by this user Quote this message in a reply
cam Offline


Posts: 1
Joined: Nov 2010
Reputation: 0
Post: #7
RE: [HowTo] Make awstats for subdomain(s)
@sidha

Did you ever figure this out? If so please share.
(This post was last modified: 11-19-2010 10:49 AM by cam.)
11-19-2010 10:48 AM
Find all posts by this user Quote this message in a reply
seoforu Offline


Posts: 1
Joined: Nov 2010
Reputation: 0
Post: #8
RE: [HowTo] Make awstats for subdomain(s)
This logfile analyzer documentation would be very useful in keeping the records.
11-20-2010 06:36 PM
Find all posts by this user Quote this message in a reply
nortol Offline


Posts: 3
Joined: Mar 2009
Reputation: 0
Post: #9
RE: [HowTo] Make awstats for subdomain(s)
we need this solution in the next generation of ispcp...
04-16-2011 09:05 AM
Find all posts by this user Quote this message in a reply
ricardon21 Offline


Posts: 1
Joined: Apr 2011
Reputation: 0
Post: #10
RE: [HowTo] Make awstats for subdomain(s)
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
04-20-2011 12:21 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


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