This how to guide will help you to install and configure AWStats Apache Log Analyzer on CentOS, RHEL and Fedora systems. This article has been tested with CentOS 7.2 only.
Step 1 – Setup EPEL Repository
Firstly install EPEL repository on your system using below command.
# yum install epel-release
Step 2 – Install Apache Server
AWStats required Apache web server to be running. If you don’t have Apache install Use below commands else you already have httpd installed skip this step.
# yum install httpd # chkconfig httpd on # service httpd start
Step 3: Install AWStats
After installing web server, Let’s install AWStats package using yum. Its will also install all other required dependencies.
# yum install awstats
Step 4 – Configure Apache for AWStats
By default AWStats creates an Apache configuration file /etc/httpd/conf.d/awstats.conf. Default configuration is ok to use except allow from access. If you need to access awstats from network, update the allow from ip with your system or network ip from where we need to access it.
# vim /etc/httpd/conf.d/awstats.conf
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/" <Directory "/usr/share/awstats/wwwroot"> Options None AllowOverride None <IfModule mod_authz_core.c> # Apache 2.4 Require host 192.168.0.0/24 </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order allow,deny Allow from 192.168.0.0/24 Allow from ::1 </IfModule> </Directory> <IfModule mod_env.c> SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins </IfModule>
Restart Apache service to reload new settings
# service httpd restart
Step 5 – Create AWStats Configuration File
Its required to create an configuration file for each of your website for which statics need to generate. Copy AWStats example configuration file with new name and make changes as below.
# cp /etc/awstats/awstats.localhost.localdomain.conf /etc/awstats/awstats.tecadmin.net.conf # vim /etc/awstats/awstats.tecadmin.net.conf
Update below settings in awstats.tecadmin.net.conf file
LogFile ="/var/log/httpd/tecadmin.net-access_log"SiteDomain ="tecadmin.net"HostAliases ="tecadmin.net www.tecadmin.net"
Now execute following command to update logs files
# perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=tecadmin.net -update
Step 6 – Schedule Cron to Update Logs
Schedule a cron job to regularly update AWStats database using newly created log entries. Add new cron job in crontab like below. Read examples of cron scheduling
0 2 * * * /usr/bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=tecadmin.net -update
Step 7 – Access AWStats in Browser
Use your server ip address or domain name to access AWStats statics. Change domain name at the end of url as per your settings.
https://tecadmin.net/awstats/awstats.pl?config=tecadmin.net
15 Comments
I am getting below error while trying to access awstats url from browser.
Invalid file path. Please check the correct URL.
Please help.
Also Please update about
How to enable username and password for access the awstat report
Thanks
Hi ,
The same Question i also have . Very simple and good article .BUt importantly we have to secure .Please share how to setup user name and password for Awstat
Thanks
Howdy, nice web site you’ve in here.
Hi,
Please could you guide, How to configure Awstats with Nginx.
I have configure all with Niginx, but unable to view it on browser, Am sure there would be a perl base configuration required for same.
Please advice.
How to do this same thing on a server which is running multiple domain under one shared IP address ??
How to configure AwStats for each domain ??
Would be great if you please update the tutorial for the same..
Good article. Saved my time.
Awesome Blog. I followed the steps, it is working on my site now,thanks
Hi.
the bellow command bug whith centos 6.5
crontab -l 0 2 * * * /usr/bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=tecadmin.net -update
crontab : option invalide — ‘c’
crontab: usage error: unrecognized option
Very good info. Lucky me I discovered your website by accident (stumbleupon).
I’ve bookmarked it for later!
your stupid plugin that spams the clipboard on copy is snipping the text so i cant copy and paste the config file… very annoying at least let the whole thing get copied
Try using nano instead of vim when i was a noob it kinda pissed me off too..
Great guide btw rahul 🙂
Hey very interesting blog!
Awesome Blog. I add this Post to my bookmarks.
nice article, very well written….