Articles in this section

How to install GeoIP php extension for PHP 7.0 and PHP 7.1 supplied by Plesk?

kb: how-to Plesk for Linux ABT: Group B

Applicable to:

  • Plesk for Linux

Question

How to install GeoIP php extension for PHP 7.0 and PHP 7.1 supplied by Plesk?

Answer

  1. Connect to the server via SSH.
  2. Install required libraries and packages:
    For RHEL/CentOS and PHP 7.0:

    # yum install make plesk-php70-devel gcc glibc-devel GeoIP-devel zlib-devel

    For RHEL/CentOS and PHP 7.1:

    # yum install make plesk-php71-devel gcc glibc-devel GeoIP-devel zlib-devel

    For Debian/Ubuntu and PHP 7.0:

    # apt-get install plesk-php70-dev build-essential
    # apt-get install libgeoip-dev geoip-bin geoip-database

    For Debian/Ubuntu and PHP 7.1:

    # apt-get install plesk-php71-dev build-essential
    # apt-get install libgeoip-dev geoip-bin geoip-database

  3. Install GeoIP v. 111 with PHP7 support:
    For PHP 7.0:

    # /opt/plesk/php/7.0/bin/pecl install http://pecl.php.net/get/geoip-1.1.1.tgz

    For PHP 7.1:

    # /opt/plesk/php/7.1/bin/pecl install http://pecl.php.net/get/geoip-1.1.1.tgz

  4. Add " extension=geoip.so" to the PHP's configuration (php.ini) file:
    For PHP 7.0 modify file /opt/plesk/php/7.0/etc/php.ini
    For PHP 7.1 modify file /opt/plesk/php/7.1/etc/php.ini
  5. Check the installation:
    For PHP 7.0:

    # /opt/plesk/php/7.0/bin/php -m | grep geoip

    For PHP 7.1:

    # /opt/plesk/php/7.1/bin/php -m | grep geoip

Note: for PHP versions other that 7.0 and 7.2, specify corresponding version in each step. For example:

# apt-get install plesk-php72-dev build-essential
# /opt/plesk/php/7.2/bin/php -m | grep geoip

Was this article helpful?

Comments

1 comment
Date Votes
  • UPDATE:
    It appears that PHP 8.x is not yet supported (https://pecl.php.net/package/geoip/1.1.1/windows)

    The only current option is to use the GeoIP2 library (https://github.com/maxmind/GeoIP2-php)


    ORIGINAL REPLY:

    This does not work as-is. Yes, I'm trying to add it to PHP 8.0-8.3 and not 7.x like the instructions states, but the geoIP extension should be compatible.

    The command:
    /opt/plesk/php/8.3/bin/pecl install http://pecl.php.net/get/geoip-1.1.1.tgz

    Errors out with:
    /tmp/geoip/geoip.c: In function 'zif_geoip_db_avail':
    /tmp/geoip/geoip.c:264:51: error: expected ')' before 'TSRMLS_CC'
    and about 100 more errors after that.

    The error happens with both Plesk GUI > Tools & Settings > PHP Settings > FPM > Manage PECL Extension and via SSH with the command above.

    I suspect that ./configure command is not able to find the proper plesk-php8x-dev file (/opt/plesk/php/8.x/bin/php-config), or that that file is using the default PHP config and not the dev package version. Haven't figured out a proper solution yet. I'll update this if I do. If you know of a solution, please share!

    0

Please sign in to leave a comment.