Install AWStats to analyze Apache logs
AWSTAT is a free Apache log file that is a very powerful log analysis tool. After analyzing logs from apache, it displays logs in easy-to-understand graphical format. Awstat is short for advanced Web statistics. It can be run on the command line interface or CGI.
In this tutorial, We will install AWSTAT on our CentOS 7 machine to analyze apache logs.
Prerequisites
1-create a website hosted on the apache web server and read the following tutorial on the apache web server,
The Epel repository is enabled on the system because the Awstat package is unavailable in the default repository. To enable epel-repo, run
$ Rpm-Uvh https://dl.Fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm
Install Awstat
Once epel-repository is enabled on the system, you can install awstat by running the command,
$ Yum install awstat
When awstat is installed, it creates a file for apache in/etc/httpd/conf. d/awstat. conf under some configurations. These configurations are useful because the Web server and awstat are configured on the same machine. However, if the awstat and the web server are on different machines, the files may change.
Configure Apache for Awstat
To configure awstat for a remote Web server, open/etc/httpd/conf. d/awstat. conf and use the IP address of the Web server to update the parameter "Allow from"
$ Vi/etc/httpd/conf. d/awstat. conf
<Directory "/usr/share/awstats/wwwroot">
Options None
AllowOverride None
<IfModulemod_authz_core.c>
# Apache 2.4
Require local
</IfModule>
<IfModule! Mod_authz_core.c>
# Apache 2.2
Order allow, deny
Allow from 127.0.0.1
Allow from 192.168.1.100
</IfModule>
</Directory>
Save the file and restart the apache service to make changes,
$ Systemctl restart httpd
Configure AWSTAT
For each website we add to awstat, we need to use website information to create different configuration files. An example file is created to the folder "/etc/awstats" through the "awstats. localhost. localdomain. conf" file name. We can copy it and configure our website,
$ Cd/etc/awstats
$ Cp awstats. localhost. localdomain. conf awstats.bkjia.com. conf
Open the file and edit the following three parameters to match your website,
$ Vi awstats.bkjia.com. conf
LogFile = "/var/log/httpd/access. log"
SiteDomain = "bkjia.com"
HostAliases = www.bkjia.com localhost 127.0.0.1
The last step is to update the configuration file, which can be done by executing the following command,
/Usr/share/awstats/wwwroot/cgi-bin/awstats. pl-config = bkjia.com-update
Check the awstat page
To test/check the awstat page, Open a Web browser and enter the following URL in the address bar,
Https://bkjia.com/awstats/awstats.pl? Config = bkjia.com
Please note that we can also schedule a cron job to regularly update awstat. Example of a crontab
$ Crontab-e
0 1 ***/usr/share/awstats/wwwroot/cgi-bin/awstats. pl-config = bkjia.com-update
Now let's end our tutorial on installing Awstat to analyze apache logs. Please leave your comments in the comment box below.
Linux Log Analysis System AWStats
AWStats log analysis in multi-host and multi-site scenarios
Use AWStats to analyze website logs-powerful log analysis tools
How to configure AWStats in Ubuntu Server