Apache

From Smop.co.uk

Jump to: navigation, search

awstats

I use awstats for showing website statistics, do be aware that if you are really serious about security you should probably not enable this on your production box.

In either case, here is what I do:

  • apt-get install awstats
  • edit /etc/awstats/awstats.conf.local:
SiteDomain=smop.co.uk
LogFormat=1
LogFile="/var/log/apache2/access.log"
  • amend /etc/logrotate.d/apache2 with these two bits:
  # for awstats
  create 640 www-data adm
  #create 640 root adm
  
  prerotate
    if [ -x /usr/lib/cgi-bin/awstats.pl ]; then
      su -c "/usr/lib/cgi-bin/awstats.pl -config=awstats -update" www-data > /dev/null
    fi
  endscript
  • chown www-data /var/log/apache2/access.log*

Now you can leave it like this and it will pick up the current access.log file. However if you want the old records:

  • remove any old awstats (in case it has just run):
    • rm /var/lib/awstats/*.txt
  • concatenate all the old logs:
    • for i in `seq 24 -1 2`; do zcat access.log.$i.gz; done > access.log.old
    • cat access.log.1 >> access.log.old
  • edit awstats.conf.local so that LogFile is set to access.log.old _only_
  • run an update manually (see /etc/cron.d/awstats)
  • revert awstats.conf.local change and delete access.log.old
Personal tools