AWSTATS
AWStats is an open source Web analytics reporting tool, suitable for analyzing data from Internet services such as web, streaming media, mail and FTP servers. AWStats parses and analyzes server log files, producing HTML reports. Data is visually presented within reports by tables and bar graphs. 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.
vim /etc/httpd/conf/httpd.conf
go line no 526
CustomLog logs/linuxjust4u.com-access_log combined
Save and restart apache.
Service httpd restart
# yum install awstats
# yum install perl-Geo-IP
Prepare the configuration file:
# cd /etc/awstats
# mv awstats.model.conf awstats.model.bak # Keep a backup of the original
# mv awstats.localhost.localdomain.conf awstats.linuxjust4u.com.conf # Change it to your domain
Edit the configuration file:
# vi /etc/awstats/awstats.linuxjust4u.com.conf
In line 51: change LogFile=”/var/log/httpd/access_log” to the location of the access_log file you want to gather statistics.
Ex: LogFile=”/var/log/httpd/linuxjust4u.com-access_log”
In line 153: change SiteDomain=”localhost.localdomain” to SiteDomain=”linuxjust4u.com”
In line 168: change HostAliases=”localhost 127.0.0.1″ to HostAliases=”www.linuxjust4u.com”
In line 203: change DirData=”/var/www/awstats” to your docroot.
Ex: DirData=”/var/www/html/awstats”
If you installed the Geo-IP plugins you need to enable it:
In line 1305 change #LoadPlugin=”geoip GEOIP_STANDARD /pathto/GeoIP.dat” to LoadPlugin=”geoip GEOIP_STANDARD /var/lib/GeoIP/GeoIP.dat”
Change the permissions to the awstats directory:
# mkdir /var/www/html/awstats
# chown -R apache:apache /var/www/html/awstats
Edit the awstats.conf to setup the aliases and restrictions:
# vi /etc/httpd/conf.d/awstats.conf
#
# Content of this file, with correct values, can be automatically added to
# your Apache server by using the AWStats configure.pl tool.
# If using Windows and Perl ActiveStat, this is to enable Perl script as CGI.
#ScriptInterpreterSource registry
#
# Directives to add to your Apache conf file to allow use of AWStats as a CGI.
# Note that path “/usr/share/awstats/” must reflect your AWStats install path.
#
Alias /awstatsclasses “/usr/share/awstats/wwwroot/classes/”
Alias /awstatscss “/usr/share/awstats/wwwroot/css/”
Alias /awstatsicons “/usr/share/awstats/wwwroot/icon/”
ScriptAlias /awstats/ “/usr/share/awstats/wwwroot/cgi-bin/”
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory “/usr/share/awstats/wwwroot”>
# Options None
Options ExecCGI
DirectoryIndex awstats.pl
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from ALL
</Directory>
# Additional Perl modules
<IfModule mod_env.c>
SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins
</IfModule>
Reload Apache:
# service httpd reload
Update your statistics:
# cd /usr/share/awstats/wwwroot/cgi-bin
# perl awstats.pl -config=linuxjust4u.com -update
If you see something like:
Create/Update database for config “/etc/awstats/awstats.linuxjust4u.com.conf” by AWStats version 6.9 (build 1.925)
From data in log file “/var/log/httpd/linuxjust4u.com-access_log”…
Phase 1 : First bypass old records, searching new record…
Direct access after last parsed record (after line 4)
Jumped lines in file: 4
Found 4 already parsed records.
Parsed lines in file: 13
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 13 new qualified records.
Then everything went fine.
If you changed your logs from common to combined it might throw some errors when you update awstats so you need to clean the log file to have only the combined logs:
# cat /dev/null > /var/log/httpd/linuxjust4u.com-access_log
run the update again:
# perl awstats.pl -config=linuxjust4u.com -update
Update for config “/etc/awstats/awstats.linuxjust4u.com.conf”
With data in log file “”
Phase 1:
Seaching new records from beginning of log file
Phase 2:
Found 2389 new qualified records.
Navigate to http://linuxjust4u.com/awstats/awstats.pl
If the update time on the upper left hand corner is the same as the time you run the awstats.pl update and you can see the statistics, then everything works fine.
Setup the cron job (it will run hourly and redirect the output to /dev/null so it’s not going to send an email to root every hour) :
cd /etc/cron.hourly
echo “perl /var/www/html/example.com/awstats/awstats.pl -config=linuxjust4u.com -update > /dev/null 2>&1″ > awstats.sh
chmod 755 awstats.sh
Now check the script
./awstats.sh
Refresh your browser and if the update time changes then you are all set.
See all statistics on your website!
Thanks.
Comments are closed, but trackbacks and pingbacks are open.