AWStats

From aldeid
Jump to navigation Jump to search

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


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



Description

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.

Installation

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 http://prdownloads.sourceforge.net/awstats/awstats-6.8.tar.gz
# tar xzvf awstats-6.8.tar.gz
# mv awstats-6.8 /usr/local/awstats

2. Installation

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

-----> 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: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.aldeid.com

-----> 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/awstats.www.aldeid.com.conf'
Config file /etc/awstats/awstats.www.aldeid.com.conf created.

-----> Add update process inside a scheduler
Sorry, configure.pl 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/awstats.pl -update -config=www.aldeid.com
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...
<<ENTER>>

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

Press ENTER to finish...
<<ENTER>>

Parameters

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/awstats.www.aldeid.com.conf

or

# nano /etc/awstats/awstats.www.aldeid.com.conf

Edit the following lines:

  • (Line 51) Definition file from which AWStats works:
LogFile="/var/log/httpd/mylog.log"
LogFile="/var/log/apache2/access.log"
  • (Line 153) Defining the site name:
SiteDomain="www.aldeid.com"
  • (Line 168) Definition of host names:
HostAliases="aldeid.com www.aldeid.com 127.0.0.1 localhost"
  • (Line 203) Definition of directory data AWStats:
DirData="/var/lib/awstats"
  • (Line 212) Setting the cgi-bin directory:
#DirCgi="/awstats"
DirCgi="/cgi-bin/awstats"
  • (Line 222) Changing the image directory:
#DirIcons="/awstatsicons"
DirIcons="/icons"
  • (Line 318) Prevents the resolution of local addresses
#SkipDNSLookupFor=""
SkipDNSLookupFor="REGEX[^192\.168\.]"

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/awstats.pl -update -config=www.aldeid.com
Create/Update database for config "/etc/awstats/awstats.www.aldeid.com.conf" 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
</Files>
Authname "Authentification"
AuthUserFile /var/www/cgi-bin/awstats/.htpasswd
AuthGroupFile /dev/null
AuthType Basic
<limit GET POST>
require valid-user
</limit>
# 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/awstats.pl -update -config=www.aldeid.com

Comments

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