AWSTATS Help FAQ for those who may need it

ziggyz27

Verified User
Joined
May 1, 2008
Messages
6
I spent 24 hours looking for this help, picked up bits n pieces here and there. So here is all that I wanted and the problems that were resolved with my AWSTATS setup.

Problems:
1. Manual Upgrade Stats_control plugin, awstats from version 6.4 to 6.9(current)

2. Fix permissions error I get consistently to fix following:
Error: Couldn't open server log file "/var/log/httpd/domains/userdomain.com.log" permission denied​

3. Process OLD logs again covering all history

My Server:
6.1-RELEASE FreeBSD
DA version 1.33.6


1. MANUAL Upgrade AWSTATS to 6.9
Goto Sourceforge and download latest version, I used following mirror:
http://nchc.dl.sourceforge.net/sourceforge/awstats/awstats-6.9.tar.gz

cd /usr/local/directadmin/plugins/Stats_Control/
wget http://nchc.dl.sourceforge.net/sourceforge/awstats/awstats-6.9.tar.gz

tar -zxvf awstats-6.9.tar.gz

#moved existing awstats to another directory
mv awstats awstats-6.4

#relinked the awstats to latest version to keep things running
ln -s awstats-6.9/ awstats

#give it proper users:group ownership
chown -R diradmin:wheel awstats-6.9/

cd awstats-6.9/

#moved all files in wwwroot/ directory to base directory of new awstats
mv wwwroot/* .
==============================================
NOTE: 6.9 version could not find my geoip module in my perl. Just added geoip from ports as follows:

cd /usr/ports/net/p5-Geo-IP/ && make install clean
=============================================
NOTE: It required me to deinstall my older version so:
cd ../net/geoip/

make deinstall

cd ../net/p5-Geo-IP/
make reinstall

==DONE===========================================

Thats it you have upgraded!

2. Fix permissions error

Well I still had that error to fix. After much research I did following:

cd /var/log/httpd/

#just the directory
chown apache:apache domains/

# NOTE this is not recommended but until I have this figured out this works
# it allows script to read all logs
chmod 777 domains/

#NOTE: All log files in domains/ are with w+x permissions and owned by root:nobody
-rwx--x--x 1 root nobody

THIS ALLOWED MY AWSTATS ERROR TO GO AWAY! I WILL UPDATE AS SOON AS I HAVE FIGURED OUT CORRECT USER:GROUP OWNERSHIP AND FILE PERMISSIONS

=====DONE=================================================

3. Process OLD logs again covering all history


#My domains logs are in following path:
#/home/user/domains/userdomain/logs/
# it has all my customer domain logs in tgz files.

-rw-r--r-- 1 root wheel 374812 Aug 1 2007 2007-08-01.tar.gz
-rw-r--r-- 1 root wheel 390497 Sep 1 2007 2007-09-01.tar.gz
-rw-r--r-- 1 root wheel 339935 Oct 1 2007 2007-10-01.tar.gz
-rw-r--r-- 1 root wheel 422753 Nov 1 2007 2007-11-01.tar.gz

NOTE: You may have some tgz files like these:

-rw-r--r-- 1 root wheel 4402 Jul 1 2008 2008-07-01(10).tar.gz
-rw-r--r-- 1 root wheel 1131 Jul 1 2008 2008-07-01(11).tar.gz
-rw-r--r-- 1 root wheel 1664 Jul 1 2008 2008-07-01(12).tar.gz
-rw-r--r-- 1 root wheel 1534 Jul 1 2008 2008-07-01(13).tar.gz

IGNORE all files with () in their names. Main files we need to use are without () brackets in their names.

#My awstats stats files are generated in
#/home/user/domains/userdomain/stats/

cd /home/user/domains/userdomain/stats/

#I created a temp/ folder in stats/
mkdir temp/

#move all previous files to temp for safe keeping
mv *com* temp/.

#back to logs directory
touch awstats_list_files
touch xtall

chmod 777 xtall

vi xtall

### COPY Following Script ####
### I wrote it myself not very cool but does the job ###
### Pay attention to <changetouserdomain> and replace it ###
### This script will process each of your tgz files one by one###
Code:
count=1
for file in `cat awstats_list_files`
do
        echo "Processing File no#"$count "->" $file

        tar -zxvf $file -C temp/

        /usr/local/directadmin/plugins/Stats_Control/awstats/cgi-bin/awstats.pl -update config=<changetouserdomain>.com -LogFile="/usr/local/directadmin/plugins/Stats_Control/awstats/tools/logresolvemerge.pl temp/<changetouserdomain>.com.*log |"

        echo "Logs processed, deleting logs"

        rm -rf temp/*.log
echo "files deleted"
echo " "
        count=`expr $count + 1`

done

Now prepare the "awstats_list_files"
List your directory and copy files block like as follows making sure there is one file name per line:

vi awstats_list_files

2007-08-01.tar.gz
2007-09-01.tar.gz
2007-10-01.tar.gz
2007-11-01.tar.gz
2007-12-01.tar.gz
2008-01-01.tar.gz
2008-02-01.tar.gz

## save file ##

#Thats it...RUN:

./xtall

#run above script and keep watching... it will process all old logs

NOTE: You may have to customize all of above script based on your server setup.
 
Back
Top