Articles in this section

How to configure GeoIP plugin for Plesk AWStats

kb: how-to Plesk for Linux

Applicable to:

  • Plesk for Linux

Question

How to configure AWStats to show visitor's country?

Answer

By default, AWStats does not show visitors by countries.

If you wish to see this functionality in AWStats for Plesk, please submit a feature request on our Product Roadmap page:

 

To enable this feature manually, configure the GeoIP plugin as follows:

 

For Plesk on CentOS/RHEL-based distributions

 

  1. Connect to your Plesk server via SSH.
  2. Install perl-CPAN package:

    # yum install perl-CPAN

  3. Install the GeoIP module using these two commands:

    # perl -MCPAN -e "install Geo::IP::PurePerl"

    # perl -MCPAN -e "install Geo::IP"

  4. 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

  5. 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

  6. 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

  7. 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

  8. Recalculate web statistics for all existing domains:

    # plesk sbin statistics --generate-all-webstat

    # plesk sbin statistics --calculate-all

For Plesk on Debian/Ubuntu-based distributions

 

  1. Connect to your Plesk server via SSH.
  2. 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

  3. Install the GeoIP module:

    # perl -MCPAN -e "install Geo::IP::PurePerl"

    # perl -MCPAN -e "install Geo::IP"

  4. 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

  5. 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

  6. Recalculate web statistics for all existing domains:

    # plesk sbin statistics --generate-all-webstat

    # plesk sbin statistics --calculate-all

Was this article helpful?

Comments

1 comment
Date Votes
  • Hi Nikita Zubovich,

    Can you please adjust the instructions, for achieveing the GEOIP on AWStats, when the GEOIP databas exists on the server, on *.dat or *.mmdb filetypes?

    Such an adjustment, may relay on:

    https://www.prosoxi.com/2009/01/27/geoip-filter-awstat-plesk/

    STEP 1 – Download and install AWStats
    • login your server as root by Putty
    • change directory and download the archive by copy and paste in Putty
    cd /usr/src

    wget http://jnsc.ch/downloads/ISPConfig_awstats_pkg_beta-3.tar.gz
    • now extract the archive, change to the directory and install it
    tar -xvzf ISPConfig_awstats_pkg_beta-3.tar.gz

    cd ISPConfig_awstats_pkg

    ./install.sh
    • now you can run AWStats to generate the first static-statistic-sites.
    /root/ispconfig/php/php /root/ispconfig/scripts/shell/awstats.php

    STEP 2 – Download and install a geographic localizer for IP´s

    cd /root

    wget http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz

    tar xzvf GeoIP.tar.gz

    cd GeoIP-1.4.0

    ./configure

    make

    make check

    make install

    wget http://www.maxmind.com/download/geoip/api/perl/Geo-IP-1.27.tar.gz

    tar xzvf Geo-IP-1.27.tar.gz

    cd Geo-IP-1.27

    perl Makefile.PL

    make

    make test

    make install

    perl -MCPAN -e shell

    install Net::XWhois

     

    • now you have to change some settings in the AWStats configuration-file
    • open and edit the file /etc/awstats/awstats.shared.conf
    Lang="de" (line 892 - "de" is an example)
    ShowScreenSizeStats=1 (line 1021)
    ShowMiscStats=anjdfrqwp (line 1041)
    LoadPlugin="geoip GEOIP_STANDARD /root/GeoIP-1.4.0/data/GeoIP.dat"(Zeile 1289)

    If you want to use AWStats in applicable extent, you have to copy the javascript to every site on your server and include the following line into your index:

    <script language="javascript" src="/js/awstats_misc_tracker.js"></script>
    
    <noscript><img src="/js/awstats_misc_tracker.js?nojs=y" height="0" width="0" border="0"style="display: none"></img></noscript>

    You can find the javascript here: /home/admispconfig/ispconfig/tools/awstats-6.5/wwwroot/js

    Run the AWStats-script to create the statistic-files

    /root/ispconfig/php/php /root/ispconfig/scripts/shell/awstats.php
    In this howto I will show you how to install MaxMind geoip on Ubuntu and how to use it.Installation
    First install the software :
    aptitude install geoip-bin
    mkdir /usr/local/share/GeoIP
    cd /usr/local/share/GeoIP
    wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
    gunzip GeoLiteCity.dat.gz
    ln -s /usr/local/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
    
    
    http://www.maxmind.com/app/perl
    GeoIP Perl API
    0

Please sign in to leave a comment.