En este post encontraréis los pasos de instalación de Awstats que es una herramienta opensource para generar informes de estadísticas basándose en los logs del servidor. Awstats soporta varios formatos de logs de servidores web entre ellos Apache, IIS, etc además de tener la ventaja de poder personalizar los mismos. 
Esta instalación la realizaremos utilizando una distribucion Ubuntu 10.01
- Instalamos el paquete de awstats con el siguiente comando
apt-get install awstats
- Localizar el siguiente fichero “awstats_configure.pl”
Resultado:
/usr/share/doc/awstats/examples/awstats_configure.pl
NOTA: El fichero "awstats_configure.pl" que se encuentra en la ruta anterior esta en una ruta ejemplo, por lo que para instalar correctamente correctamente Awstats, lo moveremos a /usr/local/awstats
- Movemos el directorio
cd /usr/share/doc/awstats
mv examples/ /usr/local/awstats
- Ejecutamos el fichero de configuración:
cd /usr/local/awstats
perl awstats_configure.pl
Resultado:
root@ip-10-48-127-145:/usr/local/awstats# perl awstats_configure.pl
----- AWStats awstats_configure 1.0 (build 1.8) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).
-----> Running OS detected: Linux, BSD or Unix
-----> 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'
All AWStats directives are already present.
-----> 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:
> website.bbvaglobalnet.com -----> Nombre del sitio web del cual necesitamos generar nuestras estadísticas
-----> 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):
>
-----> Create config file '/etc/awstats/awstats.website.bbvaglobalnet.com.conf'
Error: Failed to open '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf' for read.
- Este punto falla ya que no existe ni el fichero ni la ruta, por lo que lo crearemos a mano:
mkdir -p /usr/local/awstats/wwwroot/cgi-bin/
- El fichero awstats.model.conf se encuentra comprimido en la siguiente ruta /usr/local/awstats por lo que procedemos a descomprimirlo
root@ip-10-48-127-145:/usr/local/awstats# ll
total 180
-rw-r--r-- 1 root root 17688 2009-09-08 17:10 awstats.model.conf.gz
-rwxr-xr-x 1 root root 5504 2011-02-02 08:55 awstats_updateall.pl*
drwxr-xr-x 2 root root 4096 2012-06-21 16:35 css/
-rw-r--r-- 1 root root 2562 2008-11-15 16:03 example.pm.gz
drwxr-xr-x 2 root root 4096 2012-06-21 16:35 js/
# gunzip awstats.model.conf.gz
# mv awstats.model.conf /usr/local/awstats/wwwroot/cgi-bin/
- Ejecutamos nuevamente nuestro fichero de configuración:
# perl awstats_configure.pl
Resultado:
----- AWStats awstats_configure 1.0 (build 1.8) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).
-----> Running OS detected: Linux, BSD or Unix
-----> 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'
All AWStats directives are already present.
-----> 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:
> website.bbvaglobalnet.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):
>
-----> Create config file '/etc/awstats/awstats.website.bbvaglobalnet.com.conf'
Config file /etc/awstats/awstats.website.bbvaglobalnet.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=website.bbvaglobalnet.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...
A SIMPLE config file has been created: /etc/awstats/awstats.website.bbvaglobalnet.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'website.bbvaglobalnet.com' with command:
> perl awstats.pl -update -config=website.bbvaglobalnet.com
You can also read your statistics for 'website.bbvaglobalnet.com' with URL:
> http://localhost/awstats/awstats.pl?config=website.bbvaglobalnet.com
Press ENTER to finish...
- Awstats por defecto instala el fichero “awstats.pl” en la ruta: /usr/lib/cgi-bin/. Para mantener nuestra instalación consistente moveremos este fichero a la siguiente ruta:
# mv /usr/lib/cgi-bin/awstats.pl /usr/local/awstats/wwwroot/cgi-bin/
- Modificaremos las siguientes líneas en el fichero de configuración de apache, que especificamos durante la instalación:
vi /etc/apache/apache.conf
Modificar las siguientes lineas:
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/" Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/" Alias /awstatscss "/usr/share/awstats/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/" por Alias /awstatsicons "/usr/share/awstats/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/" ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
- Para generar las estadísticas es necesario:
Nuestros ficheros de configuración de Awstats se encuentran en la ruta: /etc/awstats
Hacemos una copia de nuestro fichero de configuración global de awstats el cual servirá como plantilla todos los dominios para los cuales queramos nuestras estadísticas
Ejemplo:
cp etc/awstats/awstats.conf /etc/awstats/awstats.site_name.conf
cp /etc/awstats/awstats.conf /etc/awstats/awstats.website.bbvaglobalnet.com.conf
- Modificamos los parámetros LogFile, SiteDomain y HostAliases en nuestro fichero de configuración para nuestro sitio
vi /etc/awstats/awstats.website.bbvaglobalnet.com.conf
Ejemplo:
LogFile="/var/log/apache2/website.log"
SiteDomain="website.com"
HostAliases="website.com www.website.com 127.0.0.1 localhost"
- Una vez modificadas las variables, podemos crear nuestras estadísticas
perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=website.bbvaglobalnet.com -configdir="/etc/awstats"
NOTA: Es muy importante especificar la opción -configdir ya que de lo contrario luego se pueden originar problemas como el siguiente:
Error: SiteDomain parameter not defined in your config/domain file. You must edit it for using this version of AWStats.
- Finalmente podemos visualizar nuestras estadísticas, introduciendo lo siguiente en nuestro navegador:
http://127.0.0.1/awstats/awstats.pl?config=website.bbvaglobalnet.com