Sabtu, 16 Januari 2016

Analyzing web traffic with awstats

http://www.freebsdmadeeasy.com/tutorials/web-server/analyze-apache-web-server-logs-with-awstats.php

Once your web server is up and running it is important to analyze your logs to see what searches are bringing users to the sites, how long they are staying, and what pages they are coming in and going out on. One of the most popular open source tools for this task is awstats.

Installing awstats from the ports

# cd /usr/ports/www/awstats
# make install
Awstats installs to /usr/local/www/awstats and needs to following lines added to your apache httpd.conf
#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/www/awstats/classes/"
Alias /awstatscss "/usr/local/www/awstats/css/"
Alias /awstatsicons "/usr/local/www/awstats/icons/"
ScriptAlias /awstats/ "/usr/local/www/awstats/cgi-bin/"

#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/www/awstats/">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
After this you will need to restart apache for the settings to take effect.
# apachectl graceful

Configuring awstats

A config file must be created for every website. These are placed in /usr/local/www/awstats/cgi-bin The awstats.model.conf is the example file so first copy it over so that you have a new one to work with.
# cp awstats.model.conf awstats.yoursite.conf
Once you have a file for your site open it and begin editting it. There are many options which are explained in the file, but the only necessary ones to change are the hostname, and any aliases used for the site. You also need to change the log type if you are not using the apache combined format.

Updating the stats

Viewing the stats is a seperate process from updating the stats. To have awstats parse your log files and update the stats daily you need to create a cron job for awstats.
30 4 * * * /usr/local/www/awstats/cgi-bin/awstats.pl
  -update -config=yoursite 
The above will update the stats using the awstats.yoursite.conf file every morning at 4:30am. Notice that for the config file awstats.yoursite.conf the awstats and conf are left off.

Updating multiple sites

Once you get a large number of sites added to awstats keeping tracking of all the crons to update them can be a problem, especially if you are trying to keep them all from running at the same time by spacing out the times. To simplify things you can use this awstats updater script to update the stats for every config file in the awstats/cgi-bin.

Viewing the stats

Now that the stats have been updated you can view them online by pointing your browser to www.yoursite.com/awstats/awstats.pl?config=yoursite

Tidak ada komentar:

Posting Komentar