Installing Awstat for analyzing Apache logs
Last updated on March 12th, 2018 at 07:35 pm
AWSTAT is free an very powerful log analyser tool for apache log files. After analyzing logs from apache, it present them in easy to understand graphical format. Awstat is short for Advanced Web statistics & it works on command line interface or on CGI.
In this tutorial, we will be installing AWSTAT on our Centos 7 machine for analyzing apache logs.
(Recommended read :Scheduling important jobs with crontab)
1- A website hosted on apache web server, to create one read below mentioned tutorials on apache web servers,
2- Epel repository enabled on the system, as Awstat packages are not available on default repositories. To enable epel-repo , run
|$ rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm|
Once the epel-repository has been enabled on the system, awstat can be installed by running,
|$ yum install awstat|
When awstat is installed, it creates a file for apache at ‘/etc/httpd/conf.d/awstat.conf’ with some configurations. These configurations are good to be used incase web server &awstat are configured on the same machine but if awstat is on different machine than the webserver, then some changes are to be made to the file.
Configuring Apache for Awstat
To configure awstat for a remote web server, open /etc/httpd/conf.d/awstat.conf, & update the parameter ‘Allow from’ with the IP address of the web server
|$ vi /etc/httpd/conf.d/awstat.conf|
Save the file & restart the apache services to implement the changes,
|$ systemctl restart httpd|
For every website that we add to awstat, a different configuration file needs to be created with the website information . An example file is created in folder ‘/etc/awstats’ by the name ‘awstats.localhost.localdomain.conf’, we can make copies of it & configure our website with this,
|$ cd /etc/awstats|
$ cp awstats.localhost.localdomain.conf awstats.linuxtechlab.com.conf
Now open the file & edit the following three parameters to match your website,
|$ vi awstats.linuxtechlab.com.conf|
Last step is to update the configuration file, which can be done executing the command below,
Checking the awstat page
To test/check the awstat page, open web-browser & enter the following URL in the address bar,
Note- we can also schedule a cron job to update the awstat on regular basis. An example for the crontab
|$ crontab –e|
0 1 * * * /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=linuxtechlab.com–update
We now end our tutorial on installing Awstat for analyzing apache logs, please leave your comments/queries in the comment box below.