Awstats: Setting up Awstats, a Web Logs Interpreter
Introduction
AWStats is a web log analyzer (but also FTP, Streaming, and mail) offering static but also dynamic graphical views of access statistics for your web servers.
It displays the number of visits, unique visitors, pages, hits, transfers by domain/country, host, time, browser, OS, etc. It can be run using CGI scripts or command line.
AWStats is free software under the GPL license.
The installation of Awstats is simple: this software interprets Apache logs (all commands to which the server responded) to provide you with understandable graphs and tables in the form of a web page.
Installation
Install Awstats using the command:
|
|
Configuration
Apache
In the configuration, I’m modifying these lines if I’m using Apache:
|
|
Displaying the web page interpreting logs will require images: you have two solutions so that the address http://your_address/awstats-icon directs to awstats images: use an Apache alias or create an awstats-icon folder in your Apache space and put the awstats images there. For this last solution, type:
|
|
Lighttpd
Use this configuration if you’re using Lighttpd:
|
|
We’ll also need to configure lighttpd:
|
|
Then we’ll activate this configuration:
|
|
Crontab and Multi-domains
By default, there is a line in the crontab that does its job well. But if you have multiple domains and therefore several configuration files in /etc/awstats/, you’ll need to be a bit tricky. I recommend commenting out the current line in this cron file:
|
|
And either add lines like:
|
|
To differentiate your domains (here deimos.fr and mavro.fr), or create a small script like this and put it in the cron instead:
|
|
A small chmod for execution rights and you’re good to go.
Protection of Awstats
You probably don’t want your statistics to be accessible from anywhere, so you can protect yourself with htaccess or something else.
htaccess under Apache
This documentation explains how to protect a directory with htaccess (login + password).
Insert these lines and adapt to your configuration (/etc/apache2/sites-enabled/000-default):
|
|
Then create a .htaccess file in /var/www/myhtaccess and add this:
|
|
Then create your access file with the user (/etc/apache2/htaccesspassword):
|
|
For the next time, to add users, just remove “-c” like this:
|
|
Don’t forget to restart apache :-)
For good documentation, follow this: Documentation on Htaccess
htdigest under Lighttpd
Htaccess files don’t exist in Lighttpd, but there is an equivalent. Check before starting that the mod_auth module is properly loaded. We’ll first generate (with -c for the first time, like htaccess) a file containing the credentials to be authorized to view a specific site:
|
|
Here I’m creating the user deimos. The realm (here ‘Authorized users only’) will allow us to differentiate between different login/password files that we can have since we can only specify one for the entire server.
Then add these lines to the global lighttpd configuration:
|
|
Then I add the protection where I need it:
|
|
Restart lighty and you’re good. The example above shows how to add the restriction where we need it, so we’ll do it by modifying our awstats configuration:
|
|
Last updated 11 Apr 2010, 15:51 CEST.