From aldeid
Jump to: navigation, search

Article Name: Introducing AWStats
Authors(s) : S├ębastien Damaye
Status : Published
Version : 2.0
Date Last Updated: 17/06/2009
Attatchments :

Description : This paper presents the fundamentals of AWStats, an analyzer of web server logs.


AWStats is a log analyzer to display statistics on access to your Web (Apache, IIS, etc.) servers. This comprehensive tool will allow you to know, among other visitors, the number of passes robots, access to your site queries, etc.



Via The Package (Version 6.5)

# apt-get install awstats

Via The Source (Version 6.8)

1. Downloading and Installing

# cd /usr/local/src
# wget
# tar xzvf awstats-6.8.tar.gz
# mv awstats-6.8 /usr/local/awstats

2. Installation

# cd /usr/local/awstats/tools
# ./

-----> Check for web server install

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
> /etc/apache2/apache2.conf

-----> Check and complete web server config file '/etc/apache2/apache2.conf'
Add 'Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"'
Add 'Alias /awstatscss "/usr/local/awstats/wwwroot/css/"'
Add 'Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"'
Add 'ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"'
Add '<Directory>' directive
AWStats directives added to Apache config file.

-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
File awstats.model.conf updated.

-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y

-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: demo
Your web site, virtual server or profile name:

-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
> <<ENTER>>

-----> Create config file '/etc/awstats/'
Config file /etc/awstats/ created.

-----> Add update process inside a scheduler
Sorry, does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/ -update
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/ now
Press ENTER to continue...

A SIMPLE config file has been created: /etc/awstats/
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for '' with command:
> perl -update
You can also read your statistics for '' with URL:
> http://localhost/awstats/

Press ENTER to finish...


1. Supply cgi-bin directory:

# mkdir -p /var/www/cgi-bin/awstats
# cp -R /usr/local/awstats/wwwroot/cgi-bin/* /var/www/cgi-bin/awstats/

2. Edit the configuration file:

# vim /etc/awstats/


# nano /etc/awstats/

Edit the following lines:

  • (Line 51) Definition file from which AWStats works:
  • (Line 153) Defining the site name:
  • (Line 168) Definition of host names:
HostAliases=" localhost"
  • (Line 203) Definition of directory data AWStats:
  • (Line 212) Setting the cgi-bin directory:
  • (Line 222) Changing the image directory:
  • (Line 318) Prevents the resolution of local addresses

3. Create destination directory stats:

# mkdir /var/lib/awstats

4. Copy icons:

# mkdir /var/www/icons
# cp -R /usr/local/awstats/wwwroot/icon/* /var/www/icons

5. Populate the database:

# perl /usr/local/awstats/wwwroot/cgi-bin/ -update
Create/Update database for config "/etc/awstats/" by AWStats version 6.8 (build 1.910)
From data in log file "/var/log/apache2/access.log"...
Phase 1 : First bypass old records, searching new record...
Direct access after last parsed record (after line 4537)
Jumped lines in file: 4537
Found 4537 already parsed records.
Parsed lines in file: 365
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 365 new qualified records.

6. Protect your directory cgi-bin/awstats

# cd /var/www/cgi-bin/awstats/
# vim .htaccess

Y See the following lines:

SetEnvIfNoCase Request_URI \.ht(access|passwd)$ ban
<Files ~ "^.*$">
order allow,deny
allow from all
deny from env=ban
Authname "Authentification"
AuthUserFile /var/www/cgi-bin/awstats/.htpasswd
AuthGroupFile /dev/null
AuthType Basic
<limit GET POST>
require valid-user
# htpasswd -c .htpasswd admin
New password: <<password>>
Re-type new password: <<password>>
Adding password for user admin

7. Automation of data refresh :

# crontab -e

For daily launch at 04:00, add;:

0 4 * * *     /usr/local/awstats/wwwroot/cgi-bin/ -update


blog comments powered by Disqus

Keywords: AWStats Apache web server statistics IIS access.log access