Here is a guide of how to install AWStats on Centos 7 running the Apache web server. This guide assumes that you already have Apache / httpd installed
Install epel-release if it isn't already installed
yum install epel-release
Install AWStats
yum install awstats
Edit the configuration to allow access from all or an IP address. Change 111.111.111.111 to your IP address, or set to all to allow all IP addresses to access it (not recommended). Save the config
vim /etc/httpd/conf.d/awstats.conf Options None AllowOverride None # Apache 2.4 Require ip 111.111.111.111 # Apache 2.2 Order allow,deny Allow from 111.111.111.111 Allow from ::1 # Additional Perl modules SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins
Restart Apache (service httpd restart if older than Centos 7)
systemctl restart httpd
cp /etc/awstats/awstats.localhost.localdomain.conf /etc/awstats/awstats.mywebsite.com.conf vim /etc/awstats/awstats.mywebsite.com.conf LogFile="/var/log/httpd/access_log" #left as is as this is where our httpd access file is SiteDomain="mywebsite.com" HostAliases="mywebsite.com www.mywebsite.com"
Update the logs file
perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=mywebsite.com -update # You should see the following Create/Update database for config "/etc/awstats/awstats.domain.com.conf" by AWStats version 7.7 (build 20180105) From data in log file "/var/log/httpd/access_log"... Phase 1 : First bypass old records, searching new record... Searching new records from beginning of log file... Phase 2 : Now process new records (Flush history on disk after 20000 hosts)... Jumped lines in file: 0 Parsed lines in file: 6853 Found 1 dropped records, Found 0 comments, Found 0 blank records, Found 65 corrupted records, Found 0 old records, Found 6787 new qualified records.
Schedule the script to run with CRON so you don't need to manually run it each time (or change root to another user)
vim /var/spool/cron/root 0 2 * * * /usr/bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=mywebsite.com -update
I decided to access AWStats from a different port, this was so not to interfere with the site itself. I added the following lines
vim /etc/httpd/conf/httpd.conf Listen 81 systemctl restart httpd
Open the firewall port for 81
firewall-cmd --zone=public --add-port=81/tcp --permanent firewall-cmd --reload
Open AWStats from the browser
http://mywebsite.com:81/awstats/awstats.pl?config=mywebsite.com
It should look something like this. Also confirm you can't access the site from other IP addresses except for your own.
Notes:
AWStats bin files sit in /usr/share/awstats/wwwroot/cgi-bin/