Tuesday, August 3, 2010

Install Awstats on Ubuntu 10.04

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.

This is how to install Awstats on Ubuntu 10.04 :-

Go to the terminal or ssh to your terminal. :- ssh 10.23.140.222 -l dzul
note change to your server ip or domain, in my case is 10.23.140.222 which is my testing server.

Then issue this command :-
sudo apt-get install awstats

If you to see the country of your visitors then :-
sudo apt-get install libnet-ip-perl
sudo apt-get install libgeo-ipfree-perl

Now we need to configure the Apache to works with awstats. Let's assume you want to analyze the Apache 2 log file of your website “yourdomain.com” (It can be just an IP address).

Create configuration file :-
sudo cp /etc/awstats/awstats.conf /etc/awstats/awstats.yourdomain.com.conf

and update these parameters :-

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

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

LogFormat=1

LoadPlugin="tooltips
LoadPlugin="geoipfree"

NOw we to run our awstats by issuing the following command :-
sudo /usr/lib/cgi-bin/awstats.pl -config=yourdomain.com -update

You should see the output something like this :-

Create/Update database for config "/etc/awstats/awstats.yourdomain.com.conf" by AWStats version 6.9(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.

After that we need to configure Apache to view the statistics. Create a file call statistics at /etc/apache2/conf.d/ directory.

cd /etc/apache2/conf.d/
nano -w statistics

and add the following parameters to that file.

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

restart your apache :-
sudo /etc/init.d/apache2 restart

if anything goes well, you're done.

To view your statistics, point to your browser like this :-
http://yourdomain.com/statistics/awstats.pl?

If you have more than one config file, then point to your browser like this :-
http://yourdomain.com/statistics/awstats.pl?config=yourdomain.com

Lastly edit your crontab and add the following parameter:-
# update every 10 min
*/10 * * * * root /usr/lib/cgi-bin/awstats.pl -config=yourdomain.com -update > /dev/null

:) Viola. Give it a try!

1 comments:

Cristiana Nicolae said...

Hello!
I have one question, maybe a silly one. I run an OS based on Ubuntu 12.04, so, I suppose that I could try to install AWStats by following your tutorial. But my blog is hosted on blogspot.com.

Now, my question: is there any way for me to use AWStats on a blogspot.com blog. For some reasons, I can't use Google Analytics so I am looking for a free alternative.

Thanks for your attention!

Post a Comment