Polls

Topics

Lighttpd Install and Configure AwStats Software Log Analyzer

Posted by Vivek on Tuesday April 29, 08 (3 weeks ago) @1:08 am

AWStats is a free powerful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a CGI or from command line and shows you all possible information your log contains, in few graphical web pages. It uses a partial information file to be able to process large log files, often and quickly. It can analyze log files from all major server tools like Apache log files (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C log format) and a lot of other web, proxy, wap, streaming servers, mail servers and some ftp servers.

You can easily configure awstats under Lighttpd web server.

Step # 1: Install awstats

Visit project web site to grab latest stable version.
# cd /tmp
# wget http://jaist.dl.sourceforge.net/sourceforge/awstats/awstats-6.7-1.noarch.rpm
# rpm -ivh awstats-6.7-1.noarch.rpm

Important Configuration Files

Step # 2: Configure lighttpd

Open lighttpd.conf file and configure perl cgi access (see tutorial for more info):
# vi lighttpd.conf
Append following configuration directive:

alias.url = (
                "/awstatsclasses" => "/usr/local/awstats/wwwroot/classes/",
                "/awstatscss" => "/usr/local/awstats/wwwroot/css/",
                "/awstatsicons" => "/usr/local/awstats/wwwroot/icon/",
                "/awstats/" => "/usr/local/awstats/wwwroot/cgi-bin/",
                "/icon/" => "/usr/local/awstats/wwwroot/icon/"
              )
# provide awstats cgi-bin access
$HTTP["url"] =~ "/awstats/" {
      cgi.assign = ( ".pl" => "/usr/bin/perl" )
}

Save and close the file. Restart lighttpd:
# /etc/init.d/lighttpd restart

Step # 3: Configure domain

Make a copy of default configuration file awstats.model.conf as awstats.domain.com.conf:
# cd /etc/awstats
# cp awstats.model.conf awstats.theos.in.conf

Open config file:
# vi awstats.theos.in.conf
Make sure you set values as follows:
LogFile="/var/log/lighttpd/theos.in/access.log"
LogFormat=1
SiteDomain="theos.in"
DirData="/home/lighttpd/theos.in/stats/awstats"

Where,

Save and close the file. Create dataDir:
# mkdir -p /home/lighttpd/theos.in/stats/awstats
# chown lighttpd:lighttpd /home/lighttpd/theos.in/stats/awstats

Step 4: Generate stats

Type the following command at a shell prompt:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=domain.com
If your domain name is theos.in, enter:
# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=theos.in
Sample output:

Create/Update database for config "/etc/awstats/awstats.theos.in.conf" by AWStats version 6.7 (build 1.892)
From data in log file "/var/log/lighttpd/theos.in/access.log"...
Phase 1 : First bypass old records, searching new record...
Direct access after last parsed record (after line 50894)
Jumped lines in file: 50894
 Found 50894 already parsed records.
Parsed lines in file: 47047
 Found 0 dropped records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 47047 new qualified records.

Step 5: View stats

Fire a web browser and type url:
http://server-ip/awstats/awstats.pl?config=domain.com
http://server-ip/awstats/awstats.pl?config=theos.in
http://theos.in/awstats/awstats.pl?config=theos.in


(Fig.01: Awstats for theos.in domain - click to enlarge)

Password protect your stats

Use mod_auth to setup a secure password protected area under Lighttpd.

Automatically update stats

Simply create a shell script to update all domains - /etc/cron.daily/01awstats via a cron job:
# vi /etc/cron.daily/01awstats
Append code as follows:

#!/bin/bash
# path to cgi-bin
AWS=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl 
 
# append your domain
DOMAINS="theos.in cyberciti.biz nixcraft.com cricketnow.in vivekgite.com"
 
# loop through all domains
for d in ${DOMAINS}
do
   ${AWS} -update -config=${d}
done

Save and close the file. Test your script:
# chmod +x /etc/cron.daily/01awstats
# /etc/cron.daily/01awstats

Recommended readings:

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or full RSS feed to get all updates. You can Email this page to a friend.

You may also be interested in...

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , , , , , , , , , , , , ~ Last updated on: April 29, 2008

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.