Install Awstats on Ubuntu

Installation


<code>sudo aptitude install awstats</code>
To see the country of your visitors (not required)


<code>
sudo aptitude install libnet-ip-perl
sudo aptitude install libgeo-ipfree-perl
</code>


Configuration


Let's assume you want to analyze the Apache 2 log file of your website “toto.com” (It can be just an IP address).


Create configuration file


<code>
sudo cp /etc/awstats/awstats.conf /etc/awstats/awstats.toto.com.conf
Update these parameters


# apache2
LogFile="/var/log/apache2/access.log"


# domain name
SiteDomain="toto.com"
HostAliases="localhost 127.0.0.1 toto.com"


LogFormat=1
You can also activate these plugins


LoadPlugin="tooltips
LoadPlugin="geoipfree"
</code>


Run


<code>sudo /usr/lib/cgi-bin/awstats.pl -config=toto.com -update</code>
You should get something like this


<code>
Create/Update database for config "/etc/awstats/awstats.toto.com.conf" by AWStats version 6.7 (build 1.892)
From data in log file "/var/log/apache2/access.log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 191338
 Found 0 dropped records,
 Found 24 corrupted records,
 Found 0 old records,
 Found 191314 new qualified records.
</code>


Configure Apache to view the statistics


Create /etc/apache2/conf.d/statistics


<code>
Alias /awstatsclasses "/usr/share/awstats/lib/"
Alias /awstats-icon/ "/usr/share/awstats/icon/"
Alias /awstatscss "/usr/share/doc/awstats/examples/css"
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /statistics/ /usr/lib/cgi-bin/
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
</code>




Restart Apache


<code>sudo /etc/init.d/apache2 restart</code>


View your statistics


http://toto.com/statistics/awstats.pl
or (in case you have more than one config file)


http://toto.com/statistics/awstats.pl?config=toto.com
Update your statistics with cron


In /etc/crontab add


<code>
# update every 10 min
*/10 * * * * root /usr/lib/cgi-bin/awstats.pl -config=toto.com -update > /dev/null
</code>


How to reset awstats


Just delete the files in /var/lib/awtstats (directory defined by DirData parameter)


<code>
sudo su - root
cd /var/lib/awstats
rm *
logout
</code>




Notes


you have to be root because for some reason, sudo rm -R awstats/* wouldn't work.
if you get the message Never updated (See 'Build/Update' on awstats_setup.html page) whereas the awstats files are there in /var/lib/awtstats, it's probably a permission problem on this folder.
Source: http://awstats.sourceforge.net/docs/awstats_faq.html#RESET


Troubleshooting


awstats "Error: SiteDomain parameter not defined in your config/domain file. You must edit it for using this version of AWStats. "
Try to this URL (with your values): http://toto.com/statistics/awstats.pl?config=toto.com


Reference


http://ubuntu-tutorials.com/2008/01/16/configuring-awstats-on-ubuntu-server/
http://www.mneylon.com/blog/archives/2005/08/03/configuring-awstats-with-apache-2-on-ubuntu/
http://awstats.sourceforge.net/
http://awstats.sourceforge.net/docs/awstats_faq.html
 

你可能感兴趣的:(Install Awstats on Ubuntu)