Difference between revisions of "Awstats"

From ArchWiki
Jump to: navigation, search
(Awstats Configuration)
Line 1: Line 1:
[[Category:Web Server (English)]]
[[Category:Web Server (English)]]
'''I am planning to update this page to contain full installation and configuration of awstats for apache as I have time to. If you want to add something, go ahead.''' ''-th0th''
== Installing ==
== Installing ==
=== mod_perl ===
=== mod_perl ===

Revision as of 23:42, 11 April 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی



mod_perl is required to run awstats with apache. ArchTrack/pkg package is available in repo extra. So you can install it using pacman.

# pacman -S mod_perl


Awstats package is available in AUR. You can use yaourt to build it or you can obtain tarball from AUR and build it yourself.

$ yaourt -S awstats


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:

 <VirtualHost *:80>
     ServerAdmin zxc@returnfalse.net
     DocumentRoot "/srv/http/xxx"
     ServerName www.returnfalse.net
     ErrorLog "/var/log/httpd/returnfalse-error_log"
     CustomLog "/var/log/httpd/returnfalse-access_log" combined

The important line here is:

 CustomLog "/var/log/httpd/returnfalse-access_log" combined
Warning: At this point, if apache has started to log access with different format, awstats will complain about this because it can't 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 to Apache's Configuration

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

 Alias /awstatsclasses "/srv/http/awstats/classes/"
 Alias /awstatscss "/srv/http/awstats/css/"
 Alias /awstatsicons "/srv/http/awstats/icon/"
 ScriptAlias /awstats/ "/srv/http/awstats/cgi-bin/"
 <Directory "/srv/http/awstats">
     Options None
     AllowOverride None
     Order allow,deny
     Allow from all

Include this file (in AUR case, the path is /etc/httpd/conf/extra/httpd-awstats.conf) to apache's main configuration:

 Include conf/extra/httpd-awstats.conf

Now if you have done all steps correctly, you should be able to see awstats running on http://domaincomeshere.com/awstats/awstats.pl of course after restarting apache. One last thing, which is the actual aim, make awstats read logs and convert them to stats.

Awstats Configuration

Package in AUR comes with a out of the box hourly cron 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 are 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):


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