Revision as of 11:56, 24 February 2014

AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a CGI or from command line and shows you all possible information your log contains, in few graphical web pages. It uses a partial information file to be able to process large log files, often and quickly. It can analyze log files from all major server tools like Apache log files (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C log format) and a lot of other web, proxy, wap, streaming servers, mail servers and some ftp servers.

Awstats

Configuration

Enable mod_perl for Apache

To enable mod_perl in Apache, you should add following line to Apache configuration (/etc/httpd/conf/httpd.conf).

LoadModule perl_module modules/mod_perl.so

Configure Apache to log for AWStats

By default AWStats requires Apache to record access logs as 'combined'. Unless you want a different behavior, you should set your access log format as 'combined'. To do so, your Apache configuration should look like this:

Warning: At this point, if apache has started to log access with different format, AWStats will complain about this because it cannot read. So if you are changing Apache's log format now, you probably should delete old log files not to confuse AWStats.

Including AWStats configuration in Apache's configuration

If you set the log format, then next step is including AWStats config file in Apache. The package in the AUR has a default one, and it's working without any problem. But in case you want to create your own configuration, default one is this:

One last thing, which is the actual aim, make AWStats read logs and convert them to stats.

AWStats Configuration

The package comes with an hourly cron script to update stats shown on AWStats. This cron script reads AWStats configuration files in /etc/awstats and updates the stats for the sites that are defined in these configuration files. Instead of creating these configuration files, you can use AWStats' configuration tool. Run:

perl /usr/share/awstats/tools/awstats_configure.pl

and follow the instructions. If you successfully created config file there is one thing that you should modify manually. Open the configuration file created by awstats_configure.pl with your favorite text editor. Then find the line on which LogFile variable is defined, and set it as the path that Apache logs accesses (which you set to be logged as 'combined' format before):

LogFile=/var/log/httpd/returnfalse-access_log

You are done, now you can run hourly cron script to test the results.

Warning: With these settings anyone will be able to reach AWStats. Setting a authentication would help keeping these stats private.

Nginx

If your web server software is nginx, follow steps below:

1. Install awstats as described above. It is necessary to get the folders and files owned by user "http" and group "http" with the following command:

chown -R http:http /usr/share/webapps/awstats/

2. Use awstats configuration tool to generate a site configuration file as described above. Make sure the following lines are set correctly:

LogFile="/var/log/nginx/access.log"
LogFormat=1

3. To make the Perl scripts of awstats work on nginx, create /etc/nginx/cgi-bin.php script with the following code: