The MaxMind GeoIP2 binary database is a custom binary format and there are two available APIs that read this binary database: MaxMind DB Reader PHP API which includes an optional C extension that you may install to improve binary database lookup performance and the default is GeoIP2 PHP API. We will discuss how to install these two APIs in your system.
The following procedures are tested on my Linode server running Centos 7 64-bit Linux distribution.
curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
Follow this instructions installing composer in Windows.
We can install GeoIP2 PHP API library in two ways: one is directly install GeoIP2 PHP API library on your Drupal base:
cd /var/www/ composer require geoip2/geoip2:~2.0
/var/www/to your Drupal root path.
... and the other way is by installing Smart IP module using composer which will install the GeoIP2 PHP API library automatically.
If you downloaded the Smart IP module directly from its project page and extracted it manually to your Drupal installation, you will want to use the first way.
(Optional) Now lets install the other API, the MaxMind DB Reader PHP API. First, install the library. Go to your Drupal root path and execute:
composer require maxmind-db/reader:~1.0
Installing MaxMind DB Reader's PHP C Extension
Install the development tools:
sudo yum install php-devel autoconf automake gcc libtool
Download and compile the libmaxminddb:
cd /opt git clone --recursive https://github.com/maxmind/libmaxminddb cd libmaxminddb/ autoreconf --install
You may encounter this (ignore it):
autoreconf: automake failed with exit status: 1
Continue with the rest of commands to compile libmaxminddb:
./bootstrap ./configure make make check sudo make install sudo ldconfig
Next, compile the PHP C extension. In your Drupal root path, execute:
cd vendor/maxmind-db/reader/ext phpize ./configure make make test sudo make install
Add the compiled PHP extension
extension=maxminddb.soin your php.ini or in
echo "extension=maxminddb.so" > /etc/php.d/maxminddb.ini
Lets check if everything are installed properly:
php -i | grep maxmind
You may encounter this error message:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/maxminddb.so' - libmaxminddb.so.0: cannot open shared object file: No such file or directory in Unknown on line 0
To solve this, execute:
sudo sh -c "echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf" sudo ldconfig
Restart your web server.
Go to http://www.mywebsite.com/admin/reports/status/php and scroll down, you should see something like this: