Giter Club home page Giter Club logo

hhvm-ext-geoip's Introduction

GeoIP (geoip) Extension for HHVM

This is a port of the PECL geoip extension for HipHop Virtual Machine.

Note: you will need to build this extension from source. Due to the number of platforms supported by HHVM, I am unable to provide binaries.

Prerequisites

This extension requires the <GeoIP.h> and <GeoIPCity.h> header files and libGeoIP library installed.

On Ubuntu 12.04, you need to install the "libgeoip-dev" and "libgeoip1" packages.

Building & Installation

Requires HHVM 3.0 or later.

If you have already built hhvm from source, build the geoip.so file (the dynamically-loadable extension) using:

$ export HPHP_HOME=/path/to/hhvm
$ cd /path/to/extension
$ ./build.sh

To build this extension without the hhvm source, try:

$ sudo apt-get install hhvm-dev libgeoip-dev
$ sudo chmod +x /usr/bin/hphpize
$ git clone https://github.com/vipsoft/hhvm-ext-geoip.git
$ cd hhvm-ext-geoip
$ hphpize
$ cmake .
$ make

To enable the extension, you need to have the following section in your PHP ini file:

hhvm.dynamic_extension_path = /path/to/hhvm/extensions
hhvm.dynamic_extensions[geoip] = geoip.so

Note: To enable the extension on older HHVM versions, you will instead have the following section in your HHVM config file:

DynamicExtensionPath = /path/to/hhvm/extensions
DynamicExtensions {
        * = geoip.so
}

Where /path/to/hhvm/extensions is a folder containing all HHVM extensions, and geoip.so is in it. This will cause the extension to be loaded when the virtual machine starts up.

Testing

To run the test suite:

$ cd /path/to/extension
$ ./test.sh run-tests.php

hhvm-ext-geoip's People

Contributors

edgarsi avatar kristapsk avatar kuroneer avatar robocoder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hhvm-ext-geoip's Issues

Build error - GeoIPLookup has not been declared

I am trying to build extension on Amazon Linux 2014.03 with HHVM 3.2.0 (compiled from source) but I am getting following error:

[root@ec2-54-77-80-163:~/hhvm-ext-geoip]$ ./build.sh
** hphpize complete, now run `cmake . && make` to build
-- Configuring done
-- Generating done
-- Build files have been written to: /root/hhvm-ext-geoip
[100%] Building CXX object CMakeFiles/geoip.dir/ext_geoip.cpp.o
In file included from /root/hhvm-ext-geoip/ext_geoip.cpp:25:0:
/root/hhvm-ext-geoip/GeoIP_internal.h:9:46: error: ‘GeoIPLookup’ has not been declared
                                              GeoIPLookup * gl);
                                              ^
/root/hhvm-ext-geoip/GeoIP_internal.h:11:49: error: ‘GeoIPLookup’ has not been declared
                                                 GeoIPLookup * gl);
                                                 ^
make[2]: *** [CMakeFiles/geoip.dir/ext_geoip.cpp.o] Error 1
make[1]: *** [CMakeFiles/geoip.dir/all] Error 2
make: *** [all] Error 2

function not found even when extension is loaded

I am trying to use the geoip extension of HHVM. I followed all instructions and installed it on my development machine and everything works fine. Then I deploy it to my live server and everything goes wrong.

I know that the extension is loaded on the live server because:

root@live:~/hhvm# hhvm --php -r 'print_r(get_loaded_extensions());'
Array
(
    [0] => apc
    [1] => array
    [2] => asio
    [3] => async_mysql
    [4] => bcmath
    [5] => bz2
    [6] => collections
    [7] => ctype
    [8] => curl
    [9] => date
    [10] => debugger
    [11] => dom
    [12] => domdocument
    [13] => enum
    [14] => exif
    [15] => fb
    [16] => fileinfo
    [17] => filter
    [18] => gd
    [19] => generator
    [20] => geoip
    [21] => hash
    [22] => hh
    [23] => hh_client
    [24] => hhvm.debugger
    [25] => hhvm.ini
    [26] => hosthealthmonitor
    [27] => hotprofiler
    [28] => iconv
    [29] => idn
    [30] => imagick
    [31] => imap
    [32] => intervaltimer
    [33] => intl
    [34] => json
    [35] => ldap
    [36] => libxml
    [37] => mail
    [38] => mailparse
    [39] => mbstring
    [40] => mcrouter
    [41] => mcrypt
    [42] => memcache
    [43] => memcached
    [44] => mysql
    [45] => mysqli
    [46] => objprof
    [47] => openssl
    [48] => pcntl
    [49] => pcre
    [50] => pdo
    [51] => pdo_mysql
    [52] => pdo_sqlite
    [53] => phar
    [54] => posix
    [55] => readline
    [56] => redis
    [57] => reflection
    [58] => server
    [59] => session
    [60] => SimpleXML
    [61] => soap
    [62] => sockets
    [63] => spl
    [64] => sqlite3
    [65] => standard
    [66] => stream
    [67] => string
    [68] => sysvmsg
    [69] => sysvsem
    [70] => sysvshm
    [71] => thread
    [72] => thrift_protocol
    [73] => tokenizer
    [74] => url
    [75] => wddx
    [76] => xenon
    [77] => xhprof
    [78] => xml
    [79] => xmlreader
    [80] => xmlwriter
    [81] => xsl
    [82] => zip
    [83] => zlib
)

But I always get this error on live:

Fatal error: Call to undefined function geoip_country_code_by_name() in

Then I also tried running this on the console:

hhvm --php -r 'print_r(geoip_country_code_by_name("www.google.com"));'
> US

Then I also tried phpinfo() and executed it on the browser which showed me:

hhvm.dynamic_extensions Array ( [0] => geoip.so )

Obviously this means that it is actually loaded on the environment of nginx. I can't seem to find the problem.

Any plans for Binaries?

Do you have any plans for pre-built binaries for Ubuntu, I've downloaded the HHVM binaries and don't have the source, upon executing ./build.sh of this extension, it gives me HPHP_HOME environment variable must be set!, is there a way to install it without source?

www.utoronto.ca returns a US-based ip

www.utoronto.ca returns a US-based ip, maybe because of the use of cloudfront.net, this causes several tests to fail.
Maybe you need to switch to utoronto.ca, which returns a CAN-based ip
This issue involves tests/102.phpt, 103.phpt, 104.phpt and 107.phpt

libGeoIP 1.6.0 compatibility testing

Library built using ./configure --prefix=/usr

FAIL Checking timezone info [tests/013.phpt] 
FAIL Checking geoip_record_by_name [tests/107.phpt] 
SKIP Checking geoip_id_by_name [tests/109.phpt] 
SKIP Checking geoip_netspeedcell_by_name [tests/112.phpt] 

Segmentation fault with latest HHVM

I tried to recompile and I get this error after recompilation

steel@BlackBeauty:/var/web/PublishSpace/Async-Redis$ hhvm
Uncaught exception: Could not load extension /usr/lib/x86_64-linux-gnu/hhvm/extensions/20150212/geoip.so: getModuleBuildInfo() symbol not defined. (/usr/lib/x86_64-linux-gnu/hhvm/extensions/20150212/geoip.so: undefined symbol: getModuleBuildInfo)

Core dumped: Segmentation fault
Stack trace in /tmp/stacktrace.26174.log
Segmentation fault

This is the stack trace

#0  ?? at hhvm:0
#1  HPHP::geoipExtension::~geoipExtension() at /usr/lib/x86_64-linux-gnu/hhvm/extensions/20150212/geoip.so:0
#2  __run_exit_handlers at /build/buildd/glibc-2.19/stdlib/exit.c:83
#3  exit at /lib/x86_64-linux-gnu/libc.so.6:0
#4  __libc_start_main at /build/buildd/glibc-2.19/csu/libc-start.c:137
#5  ?? at hhvm:0

string sub-command REGEX, mode MATCHALL needs at least 5 arguments total to command.

Installed HHVM in Centos 7 via source and then trying to install this:

[root@localhost hhvm-ext-geoip]# sh build.sh
** hphpize complete, now run cmake . && make to build
-- Configuring for HHVM API version 20140829
CMake Error at CMake/GeoIP.cmake:34 (string):
string sub-command REGEX, mode MATCHALL needs at least 5 arguments total to
command.
Call Stack (most recent call first):
config.cmake:11 (include)
CMakeLists.txt:31 (include)

-- Configuring incomplete, errors occurred!
make: *** No targets specified and no makefile found. Stop.

Getting build error executing make command

Hi,

trying to build the extension i get the following error executing the make command.

CMakeFiles/geoip.dir/build.make:54: recipe for target 'CMakeFiles/geoip.dir/ext_geoip.cpp.o' failed
make[2]: *** [CMakeFiles/geoip.dir/ext_geoip.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/geoip.dir/all' failed
make[1]: *** [CMakeFiles/geoip.dir/all] Error 2
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2

Details to the system:
3.16.0-4-amd64 #1 SMP Debian (jessie) 3.16.7-ckt11-1+deb8u3 (2015-08-04) x86_64 GNU/Linux

HipHop VM 3.17.1 (rel)
Compiler: tags/HHVM-3.17.1-0-gdb3429c2130e5f7539bfd550c27a6bea9444b669
Repo schema: 68c9b831b56bea5d8c90f6fca5ea358cdaaea626

What am I doing wrong.

Thanks in advance
Greets

Segmentation Fault with latest HHVM

I downloaded the latest binaries of HHVM today, it worked fine with the last build. But today it threw Segmentation fault whenever I started it. I had to remove the GEO-IP extension from list to boot it up.
Any ideas how can I make them both work together in harmony?

Call to unimplemented native function geoip_region_name_by_code()

I'm using the function geoip_region_name_by_code in my php-code. But hhvm returns:
Fatal error: Call to unimplemented native function geoip_region_name_by_code() in ...
The extension is loaded, because I got the message
Warning: geoip_record_by_name(): Required database not available at /usr/share/GeoIP/GeoIPCity.dat.
before I installed the GeoIPCity.dat database. Since that, I get the error above.

The system is Ubuntu 12.04LTS with HHVM from the HHVM-Repo.

Build error on HHVM 3.6-dev

root@zoom:/tmp/hhvm-ext-geoip# make
Scanning dependencies of target geoip
[100%] Building CXX object CMakeFiles/geoip.dir/ext_geoip.cpp.o
In file included from /usr/include/hphp/runtime/base/base-includes.h:24:0,
                 from /tmp/hhvm-ext-geoip/ext_geoip.cpp:21:
/usr/include/hphp/runtime/ext/extension.h:26:34: fatal error: hphp/runtime/version.h: No such file or directory
 #include "hphp/runtime/version.h"
                                  ^
compilation terminated.
make[2]: *** [CMakeFiles/geoip.dir/ext_geoip.cpp.o] Error 1
make[1]: *** [CMakeFiles/geoip.dir/all] Error 2
make: *** [all] Error 2
root@zoom:/tmp/hhvm-ext-geoip# hhvm --version
HipHop VM 3.6.0-dev (rel)
Compiler: heads/master-0-g4d9b5b19afc0581856c79298f0672d7b55df9339
Repo schema: dd4735ca46a0f3085a288777a8b8be4fca156b07

Test/Fix "skipped" tests

  • 105.phpt - requires GEOIP_ISP_EDITION
  • 106.phpt - requires GEOIP_ORG_EDITION
  • 108.phpt - requires region edition
  • 109.phpt - requires netspeed edition

Segmentation fault libGeoIP - 1.6.1

hhvm and hhvm-ext-geo-ip from repositories
libGeoIP - 1.6.1

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x2aaac55ff940 (LWP 5828)]
0x00002aaab8c48689 in _GeoIP_setup_dbfilename () at GeoIP.c:815
815 GeoIPDBFileName[GEOIP_USERTYPE_EDITION] = _GeoIP_full_path_to(
(gdb) bt
#0 0x00002aaab8c48689 in _GeoIP_setup_dbfilename () at GeoIP.c:815
#1 0x00002aaab8c488b1 in GeoIP_db_avail (type=1) at GeoIP.c:900
#2 0x00002aaab8a2f8c4 in HPHP::geoipExtension::updateCustomDirectory (value=...) at /root/hhvm/hhvm-ext-geoip/ext_geoip.cpp:840
#3 0x000000000102f70e in std::_Function_handler<bool (std::string const&), bool (*)(std::string const&)>::_M_invoke(std::_Any_data const&, std::string const&) (__functor=..., __args#0=...)

at /root/hhvm/build/gcc49/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/functional:2025

info sharedlibrary
x00002aaab88142f0 0x00002aaab8820fc8 Yes /opt/hhvm/lib/hphp/extensions/20140702/geoip.so
0x00002aaab8a31cc0 0x00002aaab8a46b68 Yes /opt/hhvm/lib/libGeoIP.so.1

ls -la /opt/hhvm/lib/libGeoIP*
lrwxrwxrwx 1 root root 17 Jul 7 21:58 /opt/hhvm/lib/libGeoIP.so.1 -> libGeoIP.so.1.6.1
-rwxr-xr-x 1 root root 929820 Jul 7 21:58 /opt/hhvm/lib/libGeoIP.so.1.6.1

segfault happens after some time
I can repeat it locally with ab -c 20 -n 1000 ...url for checking geo ip

php code some like

        if (function_exists('geoip_db_avail') && geoip_db_avail(GEOIP_CITY_EDITION_REV1)) {
              $geoIpInfo = @geoip_record_by_name($ip);
            $result = 'Result : ' . print_r($geoIpInfo, true);
        } 

though, I will check with prev version of libGeoIP

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.