WebFaction
Community site: login faq

I'm trying to install PECL extension GeoIP but with no luck.

mkdir ~/pecl_install
cd ~/pecl_install
wget http://pecl.php.net/get/geoip-1.0.8.tgz
tar xzvf geoip-1.0.8.tgz
cd geoip-1.0.8
phpize54
./configure --with-php-config=/usr/local/bin/php54-config

And then I'm getting this:

./configure --with-php-config=/usr/local/bin/php54-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php54 -I/usr/local/include/php54/main -I/usr/local/include/php54/TSRM -I/usr/local/include/php54/Zend -I/usr/local/include/php54/ext -I/usr/local/include/php54/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20100525
checking for PHP installed headers prefix... /usr/local/include/php54
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for geoip support... yes, shared
checking for geoip files in default path... not found
configure: error: Please reinstall the geoip distribution

I was trying to find some info about this and one thing that I found is that I need to do yum install geoip-devel. But I can't do yum since I'm on shared hosting. Any suggestions?

UPDATE I solved my issue. Found way to install libGeoIP

wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
tar xzvf GeoIP.tar.gz 
cd GeoIP-1.4.8
./configure --prefix=$HOME
make
make install

Then I modified configure file inside $HOME/pecl_install/geoip-1.0.8

Added my home path to SEARCH_PATH on line 4141.

So now it looks like SEARCH_PATH="/usr/local /usr /sw /opt/local /home/myusername"

And then:

./configure --with-php-config=/usr/local/bin/php54-config
make
cp modules/geoip.so ~/php54-exts/
echo "extension_dir = $HOME/php54-exts" >> ~/webapps/<appname>/php.ini
echo "extension = geoip.so" >> ~/webapps/<appname>/php.ini

Finally it works!

asked 12 Jun '13, 04:24

HarrisonHill
1113
accept rate: 0%

edited 12 Jun '13, 07:07


To install geoip-devel manually you would need to download it and compile it from sources:

cd ~/pecl_install
curl  --silent http://www.maxmind.com/download/geoip/api/c/GeoIP-latest.tar.gz | tar xz
cd GeoIP-1.5.1
./configure --prefix=$HOME
make
make install

Then, you would need to edit line 4141 in your ~/pecl_install/geoip-1.0.8/configure file and add your home directory in the list of directories configure searches for the geoip library.

Since my username is ilias, I would change the line from SEARCH_PATH="/usr/local /usr /sw /opt/local" to SEARCH_PATH="/home/ilias /usr/local /usr /sw /opt/local"

Running ./configure --with-php-config=/usr/local/bin/php54-config and them make, would create the needed file in the modules directory.

You would then need to customize your php.ini file to include those using the extension_dir directive. See the similar How do I install the Imagick PECL extension for my PHP 5.3 application? for further info.

permanent link

answered 12 Jun '13, 06:38

iliasr ♦♦
2.2k14
accept rate: 34%

edited 12 Jun '13, 06:39

Oops, sorry, didn't see your post before updating my question. I found same solution. Thank you very much for help! :)

(12 Jun '13, 07:09) HarrisonHill

You can get it working without PECL too.

http://www.maxmind.com/app/geolitecity

cd ~/3rdParty/geoip
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
wget https://raw.github.com/maxmind/geoip-api-php/master/geoipcity.inc

<?php
require_once "~/3rdParty/geoip/geoipcity.inc";
$gi = geoip_open("~/3rdParty/geoip/GeoLiteCity.dat", GEOIP_STANDARD);
$location = geoip_record_by_addr($gi, $_SERVER['REMOTE_ADDR']);
print_r($location);
?>
permanent link

answered 12 Jun '13, 04:57

epqrs
16921433
accept rate: 0%

Thanks, but my app has already integrated all the functionality. It will take lots of code rewriting to get it working with this. Plus I need orgs and isps as well. Hope there is way to get it working with PECL

(12 Jun '13, 05:02) HarrisonHill

The full scripted commands should be (for PHP 5.6) as follows:

Install re2c:

mkdir -p $HOME/tmp/src
cd $HOME/tmp/src
wget 'http://downloads.sourceforge.net/project/re2c/re2c/0.14.3/re2c-0.14.3.tar.gz'
tar -xf re2c-0.14.3.tar.gz
cd re2c-0.14.3
./configure --prefix=$HOME
make
make install

Install GeoIP database:

mkdir -p $HOME/tmp/src
cd $HOME/tmp/src
wget 'http://www.maxmind.com/download/geoip/api/c/GeoIP-latest.tar.gz'
tar -xf GeoIP-latest.tar.gz
cd GeoIP-*
./configure --prefix=$HOME
make
make install

Install GeoIP PECL Extension:

mkdir -p $HOME/tmp/src
cd $HOME/tmp/src
wget 'http://pecl.php.net/get/geoip-1.0.8.tgz'
tar -xf geoip-1.0.8.tgz
cd geoip-1.0.8
phpize56
export PATH=$HOME/bin:$PATH
sed -i "s^SEARCH_PATH=\"/usr/local /usr /sw /opt/local\"^SEARCH_PATH=\"$HOME /usr/local /usr /sw /opt/local\"^" ./configure
./configure --with-php-config=/usr/local/bin/php56-config
make
mkdir -p $HOME/php56-exts
cp modules/geoip.so $HOME/php56-exts/
ln -s /usr/local/lib/php56/extensions/no-debug-non-zts-20131226/* $HOME/php56-exts/

Hope that helps!

permanent link

answered 23 Jun '15, 02:30

ryans ♦♦
5.0k103860
accept rate: 43%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×265
×10
×10

question asked: 12 Jun '13, 04:24

question was seen: 15,152 times

last updated: 23 Jun '15, 02:30

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM