Nom de l'article : Présentation de AWStats
Auteur(s) : Sébastien DAMAYE
Statut : publié
Version : 2.0
Date dernière mise à jour : 17/06/2009
Mots clés : statistiques serveur web awstats apache iis access.log accès
Pièces jointes :
Description : Cet article présente les fondamentaux de AWStats, un analyseur de logs de serveurs Web.
AWStats est un analyseur de logs permettant d'afficher des statistiques sur les accès à vos serveurs Web (Apache, IIS, etc.). Cet outil très complet vous permettra entre autres de connaître les visiteurs, le nombre de passages des robots, les requêtes d'accès à votre site, etc.
# apt-get install awstats
1. Téléchargement et installation
# 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>>
1. Alimentation du répertoire cgi-bin :
# mkdir -p /var/www/cgi-bin/awstats # cp -R /usr/local/awstats/wwwroot/cgi-bin/* /var/www/cgi-bin/awstats/
2. Modifier le fichier de configuration
# vim /etc/awstats/awstats.www.aldeid.com.conf
Modifier les lignes suivantes :
(ligne 51) Définition du fichier à partir duquel Awstats travaille
#LogFile="/var/log/httpd/mylog.log" LogFile="/var/log/apache2/access.log"
(ligne 153) Définition du nom du site
SiteDomain="www.aldeid.com"
(ligne 168) Définition des noms de l'hôte
HostAliases="aldeid.com www.aldeid.com 127.0.0.1 localhost"
(ligne 203) Définition du répertoire des données Awstats
DirData="/var/lib/awstats"
(ligne 212) Définition du répertoire cgi-bin
#DirCgi="/awstats" DirCgi="/cgi-bin/awstats"
(ligne 222) Modification du répertoire des images
#DirIcons="/awstatsicons" DirIcons="/icons"
(ligne 318) Empêche la résolution des adresses locales
#SkipDNSLookupFor="" SkipDNSLookupFor="REGEX[^192\.168\.]"
3. Créer répertoire de destination des stats
# mkdir /var/lib/awstats
4. Copier les icônes :
# mkdir /var/www/icons # cp -R /usr/local/awstats/wwwroot/icon/* /var/www/icons
5. Peupler la base de données
# 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. Protéger votre répertoire cgi-bin/awstats
# cd /var/www/cgi-bin/awstats/ # vim .htaccess
Y reporter les lignes suivantes :
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. Automatisation du rafraîchissement des données :
# crontab -e
Pour un lancement quotidien à 04:00, ajouter :
0 4 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.aldeid.com