jump to navigation

awstats May 24, 2011

Posted by pisethkem in Computer, Linux.
trackback

Installation:
*************

sudo aptitude install awstats

To see the country of your visitors (not required)

sudo aptitude install libnet-ip-perl
sudo aptitude install libgeo-ipfree-perl

Configuration:
**************

cd /usr/local/
sudo mkdir awstats
sudo mkdir awstats/wwwroot
sudo mkdir awstats/wwwroot/cgi-bin

sudo cp -r /usr/share/doc/awstats/examples/* /usr/local/awstats/

cd /usr/local/awstats/
sudo gunzip awstats.model.conf.gz

sudo mv awstats.model.conf wwwroot/cgi-bin/
sudo ln -s /usr/local/awstats/css/ wwwroot/
sudo ln -s /usr/share/awstats/* wwwroot/
sudo ln -s /usr/lib/cgi-bin/awstats.pl wwwroot/cgi-bin/
sudo chown -R www-data:www-data wwwroot
sudo chown -R www-data:www-data /var/lib/awstats/
sudo chown root:www-data /var/log/apache2/access.log

[or other log files for site specific]

sudo cp /etc/awstats/awstats.conf /etc/awstats/awstats.yourdomain.conf

–Update these parameters:

LogFile=”/var/log/apache2/yourlogfile.log”
SiteDomain=”yourdomain”
HostAliases=”yourdomain www.yourdomain localhost”

LogFormat=1
LogType=W
DNSLookup=1
DirData=”/var/lib/awstats/”

–You can also activate these plugins

LoadPlugin=”tooltips”
LoadPlugin=”geoipfree”

Run:
****

sudo /usr/lib/cgi-bin/awstats.pl -config=yourdomain -update

Configure Apache to view the statistics:
****************************************
++Backup apache2

$sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.backup

Add these lines to the end of apache2.conf:

#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses “/usr/local/awstats/wwwroot/classes/”
Alias /awstatscss “/usr/local/awstats/wwwroot/css/”
Alias /awstatsicons “/usr/local/awstats/wwwroot/icon/”
ScriptAlias /awstats/ “/usr/local/awstats/wwwroot/cgi-bin/”
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory “/usr/local/awstats/wwwroot”>
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128 192.168.1.1/24
</Directory>

sudo /etc/init.d/apache2 restart

[now you can access from]

http://yourdomain/awstats/awstats.pl?config=yourdomain

Update your statistics with cron:
*********************************

In /etc/crontab add

# update every 30 min
*/30 * * * * root /usr/lib/cgi-bin/awstats.pl -config=yourdomain -update > /dev/null

How to reset awstats:
*********************
sudo rm /var/lib/awstats/*

Notes after configurations:
*-*-*-*-*-*-*-*-*-*-*-*-*-*

—–> Create config file ‘/etc/awstats/awstats.xyz.edu.kh.conf’
Config file /etc/awstats/awstats.xyz.edu.kh.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=xyz.edu.kh
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.xyz.edu.kh.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for ‘xyz.edu.kh’ with command:
> perl awstats.pl -update -config=xyz.edu.kh
You can also read your statistics for ‘xyz.edu.kh’ with URL:
> http://localhost/awstats/awstats.pl?config=xyz.edu.kh

Press ENTER to finish…

Advertisement

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.