Awstats is an advanced graphical statistics software that can be used to analyze the webserver logs. Here we can see how we can install awstats on a linux server with Apache.
Installation
You can get the latest awstats from here. Login to server as root execute the below commands
# cd /usr/local/
# wget http://sourceforge.net/projects/awstats/files/AWStats/7.0/awstats-7.0.tar.gz
# tar -zxvf awstats-7.0.tar.gz
# mv /usr/local/awstats-7.0 /usr/local/awstats
# cd /usr/local/awstats/tools/
# perl awstats_configure.pl
The above script will ask few questions, detect/modify your apache configuration and will generate an awstats configuration file for the site you specifies.
Configuration
Awstats site configuration file path will be : /etc/awstats/
Name Format of configuration file : awstats.yoursite.com.conf
Open the configuration file with a desired text editor and check, verify and modify the below entries
LogFile —> Log file directive should mention the correct path of the site access log file
SiteDomain —> this directive should mention your domain name
Updating stats
You can update stats with the below command
# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=yoursite.com
Add it as a cron to generate the statistics periodically
# crontab -e
0 0 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=yoursite.com >/dev/null 2>&1
Securing
To restrict access and to password protect the statistic information add the below lines in your apache configuration
<Files “awstats.pl”>
AuthUserFile /usr/local/awstats/.htpasswd
AuthGroupFile /path/to/.group
AuthName “Restricted Area”
AuthType Basic
require valid-user
</Files>
You need to create a user and password and copy it to the file /usr/local/awstats/.htpasswd to limit the access. Any htpasswd online generator can be used for this, You can find an example one here
restart Apache
/etc/init.d/httpd restart
Accessing
Awstats of the domain can be viewed with the url,
http://your_server_ip/awstats/awstats.pl??config=yoursite.com