Applicable to:
- Plesk for Linux
Question
How to configure AWStats to show which countries visitors are from?
Answer
By default, AWStats does not show visitors by countries.
If you wish to see this functionality in AWStats for Plesk out of the box, please vote for this feature on Plesk UserVoice:
To enable this feature manually, configure the GeoIP plugin manually:
-
Connect to your Plesk server via SSH.
-
Install
perl-CPAN
package:# yum install perl-CPAN
-
Install the GeoIP module using these two commands:
# perl -MCPAN -e "install Geo::IP::PurePerl"
# perl -MCPAN -e "install Geo::IP"
-
Run these commands to uncomment the plugin in AWStats configuration files:
# /bin/sed -ire '/GeoIP.dat/ s/^#//' /etc/awstats/awstats.conf
# /bin/sed -ire '/GeoIP.dat/ s/^#//' /etc/awstats/awstats.model.conf
-
Run these commands to correct the path:
# /bin/sed -i 's/\/pathto\/GeoIP.dat/\/usr\/share\/GeoIP\/GeoIP.dat/g' /etc/awstats/awstats.conf
# /bin/sed -i 's/\/pathto\/GeoIP.dat/\/usr\/share\/GeoIP\/GeoIP.dat/g' /etc/awstats/awstats.model.conf
-
Run this command to uncomment the line for all existing domains which are using AWstats:
# for file in /usr/local/psa/etc/awstats/*; do /bin/sed -ire '/GeoIP.dat/ s/^#//' "$file"; echo "$file is updated"; done
-
Run this command to correct path to GeoIP plugin:
# for file in /usr/local/psa/etc/awstats/*; do /bin/sed -i 's/\/pathto\/GeoIP.dat/\/usr\/share\/GeoIP\/GeoIP.dat/g' "$file"; echo "$file is updated"; done
-
Recalculate web statistics for all existing domains:
# plesk sbin statistics --generate-all-webstat
# plesk sbin statistics --calculate-all
-
Connect to your Plesk server via SSH.
-
Check if the
make
utility is installed on the server:# which make
If this command's output is empty, install the required package:
# apt-get install make
-
Install the GeoIP module:
# perl -MCPAN -e "install Geo::IP::PurePerl"
# perl -MCPAN -e "install Geo::IP"
-
Run these commands to uncomment the plugin in AWStats configuration files:
# /bin/sed -ire '/GeoIP.dat/ s/^#//' /etc/awstats/awstats.conf
# /bin/sed -ire '/GeoIP.dat/ s/^#//' /etc/awstats/awstats.model.conf
-
Run this command to uncomment the line for all existing domains which are using AWstats:
# for file in /usr/local/psa/etc/awstats/*; do /bin/sed -ire '/GeoIP.dat/ s/^#//' "$file"; echo "$file is updated"; done
-
Recalculate web statistics for all existing domains:
# plesk sbin statistics --generate-all-webstat
# plesk sbin statistics --calculate-all
Comments
9 comments
I have followed these instructions and now AWStats shows the country info for my websites. However, in my biggest site AWStats has only been able to detect a 0,15% of the hits (5,080 out of 3,200,470)
According to this info (https://dev.maxmind.com/geoip/geoip2/geolite2/) GeoIP dabatases were discontinued on January 2, 2019. So, my question is, is it possible to update the AWStats version used by Plesk to use GeoLite2? If so, how?
Thank you very much in advance.
@Ramón
There is no reliable solution to use GeoLite2 in AWStats so far. Workarounds and development is under discussion here - https://github.com/eldy/awstats/issues/86
Thank you so much for your reply Denis,
I tried the suggested steps and versions, but it seems I am out of luck :-( I guess I will have to wait to an official update.
Thank you for the link, though.
All the best,
Slightly related question... How do I get AWStats to resolve the IP addresses? I assume the logresolvemerge tool is not running to resolve the IP addresses in AWStats reports.
@Bob B
Check whether you have log anonymization enabled in Plesk > Tools & Settings > Server Settings > Anonimyze IPs during log rotation. If so, disable it.
@Alisa Kasyanova
Log anonymization is off. Any other ideas?
@Bob B
Do you have a custom Virtual Host template? It can modify the log format, and webstatistics calculation will be broken as webstat tools (Webalizer and Awstats) use CLF (Common Log Format) when each line in a file stored in the Common Log Format has the strictly defined syntax.
If you use default templates, feel free to submit a support request as per https://support.plesk.com/hc/en-us/articles/213608509-How-to-submit-a-request-to-Plesk-support- .
I got this error when executing perl -MCPAN -e "install Geo::IP::PurePerl"
Can't locate CPAN.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.
Please help
Hi Sharul Hafiz,
You have to install CPAN first, your Perl doesn't have it: https://www.linuxquestions.org/questions/programming-9/can%27t-locate-cpan-pm-in-%40inc-748833/
Please sign in to leave a comment.