Lighttpd Install and Configure AwStats Software Log Analyzer

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
# rpm -ivh awstats-6.7-1.noarch.rpm

Important Configuration Files

  • /usr/local/awstats/wwwroot/ – Default installtion directory
  • /etc/awstats/ – Configuration file for all your domains
  • /usr/local/awstats/wwwroot/cgi-bin/ : Main program directory
  • /var/log/lighttpd/ : Web server access log file
  • /home/lighttpd/ : Web root for your domain
  • /home/lighttpd/ : Directory to store awstats data files. You need to create this directory.

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
# cd /etc/awstats
# cp awstats.model.conf

Open config file:
# vi
Make sure you set values as follows:


  • LogFile : Defines the web, ftp or mail server log file to analyze. A full path to your log file /var/log/lighttpd/
  • LogFormat : Use Apache / Lighttpd combined log format
  • DirData : When AWStats updates its statistics, it stores results of its analysis in files (AWStats database). All those files are written in the directory defined by the “DirData” parameter. Set this value to the directory where you want AWStats to save its database and working files into.

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

Step 4: Generate stats

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

Create/Update database for config "/etc/awstats/" by AWStats version 6.7 (build 1.892)
From data in log file "/var/log/lighttpd/"...
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:

(Fig.01: Awstats for 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:

# path to cgi-bin
# append your domain
# loop through all domains
for d in ${DOMAINS}
   ${AWS} -update -config=${d}

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

Recommended readings:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 9 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
9 comments… add one
  • tony Sep 12, 2008 @ 19:02

    I got this error when trying to install the awstats RPM package:

    error: Failed dependencies:
    perl(LWP::UserAgent) is needed by awstats-6.8-1.noarch

  • yoander Sep 22, 2008 @ 1:08

    You must install this module. You can do that through a cpan install

  • Roon Oct 28, 2008 @ 0:18

    I am getting a 403 when trying to access the from in my browser.
    Updating the stats worked fine, and I can see the file listed if I just browse to /awstats/

    Any ideas?

  • tony Oct 28, 2008 @ 1:10

    403 error: you have problem with permission of awstats directory, check on that.

  • Roon Oct 28, 2008 @ 10:10

    Problem solved, I only required the /awstats/ and /icons/ aliases, the others were causing problems.


  • Vinny Mar 16, 2011 @ 14:04


    I’m using Debian 6 and Lighttpd as webserver and tomcat as App server. When I install AWstats, /usr/local/awstats folder is not being created. So where can I find the folder paths for ALIAS?

  • JaÅ¡a Oct 21, 2011 @ 22:16

    Vinny, use this command to find out which files the awstats package installs:
    dpkg -L awstats | less

    I have a question myself: If I use logrotate for the log, does awstats remember the old data (I suppose so because of the DB) and where in the log it has been?

  • Jason Mar 25, 2012 @ 1:38

    If you get a 403 error like me, make sure you have mod_cgi enabled in your lighttpd conf. I only had mod_fastcgi enabled.

  • Mike Apr 16, 2012 @ 19:05

    Make sure you run:
    lighttpd-enable-mod accesslog
    and then restart lighttpd. Access logs are not enabled by default.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum