Ivan Tomica

Enable GeoIP on PHP 7.0 on FreeBSD

Since pecl extension is compiled against PHP 5.6 in official FreeBSD repositories you’ll need to manually compile this PECL extension to have it included in PHP 7.0. Luckily for you process is really simple.

Install autoconf so PHP can detect variables:

pkg install autoconf

Download latest PECL extension version from PHP’s website:

fetch https://pecl.php.net/get/geoip-1.1.1.tgz

Extract and configure it:

tar -xzvf geoip-1.1.1.tgz
cd geoip-1.1.1/
./configure

Finally, compile and install:

make
make install

To have it loaded by your PHP-FPM (assuming you’re using it) include it in your php.ini configuration. I did it by creating /usr/local/etc/php/ext-99-geoip.ini file with following contents:

extension=geoip.so

As extension is in PHP’s library PATH by default.

Tagged in:,