#!/bin/bash # should contain subdirectories and log files for each of the Apache domains or subdomains # For instance: If you want to add a subdomain: my.domain.com you should create # the directory /var/log/apache2/my-domaincom/ ,the directory should contain both access.log and error.log files # The script would automatically substitute all "-" dashes with "." to be able to properly work # you should always follow a syntax when creating new subdirectories for new domains in /var/log/apache2/ # Let's say you'd like to add a newdomain name called newdomain.com, then you should create # the directory /var/log/apache2/newdomaincom/ and it should contain both access.log and error.log files # Hope you got the idea # Preliminary make sure you have configured your VirtualHosts to log to a proper locations the script assumes # that Apache would have directives for each of our domains Virtualhosts as follows: # ErrorLog /var/log/apache2/newdomaincom/error.log # CustomLog /var/log/apache2/newdomaincom/access.log combined # Also you should configure the script variable: # (apache_log_file) to point to your original apache log file - This variable's value should be identical to the value # of LogFile="/var/log/apache2/access.log" in /etc/awstats/awstats.conf otherwise the script won't work # (domain_name_orig) variable should be configured to be identical to the # /etc/awstats/awstats.conf's variable SiteDomain="domainname.com" # (index_page) should be set to a location where you want to have html with links to awstats statistics # to all your domains generated from the logs # To make the script execute routinely use crond # On Debian Linux edit your /etc/cron.d/awstats # comment the line # 0,10,20,30,40,50 * * * * www-data [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.conf -a -r /var/log/apache2/access.log ] && /usr/lib/cgi-bin/awstats.pl -config=awstats -update >/dev/nul # Then add something similar to: # 0,10,20,30,40,50 * * * * www-data cd /etc/awstats/awstats; /etc/awstats/awstats_generate_for_multiple_sites.sh 2>&1 >/dev/null # in the above cron definition I assume you're storing the awstats_generate_for_multiple_sites.sh script in /etc/awstats/ directory. # # This script is licensed under GPL ver. 3.0 # http://www.gnu.org/licenses/gpl-3.0.txt loop_dir=/var/log/apache2; domain_name_orig='domain_name.com'; apache_log_file='/var/log/apache2/access.log'; index_page=/var/www/awstats/index.html; awstats_conf=/etc/awstats/awstats.conf; Webstatistics_for="Your Company Name"; apache_log_file_name='access.log'; awstats_url="http://www.domain.com/cgi-bin/awstats.pl?config"; awstats_location='/usr/lib/cgi-bin/awstats.pl'; cat /dev/null > $index_page; echo "" >> $index_page; echo "
" >> $index_page; echo "