Results 1 to 20 of 20

Thread: Unable to install geoip

  1. #1
    Join Date
    Dec 2008
    Posts
    518

    Unable to install geoip

    Hi

    I just update my server to php 5.6
    But I'm unable to activate GeoIP

    I read a lot of google page, but always nothing work.

    When I send php -m, there is no geoip module


    My installation :

    Centos 6.8
    php1_release=5.6
    php1_mode=php-fpm
    php2_release=5.3 (no more used)
    php2_mode=php-fpm


    My prefer method is to use $_SERVER['GEOIP_COUNTRY_CODE'] as before.
    But actually, I've an error if I had (in custom httpd conf)
    Code:
    GeoIPEnable On
    GeoIPDBFile /usr/local/geoip/share/GeoIP/GeoIP.dat
    Invalid command 'GeoIPEnable', perhaps misspelled or defined by a module not included in the server configuration

    Thanks for your help.
    I feel a little dubbious, with this simple problem !

  2. #2
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,060
    Hello,

    To install the module you should use PECL and/or phpize:

    http://php.net/manual/en/install.pecl.phpize.php
    http://php.net/manual/en/install.pecl.pear.php

    then update php.ini

    example: https://help.directadmin.com/item.php?id=400
    Regards, Alex G.

    - You can hire me on www.poralix.com to work on your server
    - Follow and like @Poralix on Facebook

  3. #3
    Join Date
    Dec 2008
    Posts
    518
    thanks zEitEr

    Code:
    pecl install geoip
    downloading geoip-1.0.8.tgz ...
    Starting to download geoip-1.0.8.tgz (10,061 bytes)
    .....done: 10,061 bytes
    5 source files, building
    WARNING: php_bin /usr/local/php56/bin/php appears to have a suffix 56/bin/php, but config variable php_suffix does not match
    running: phpize56
    Configuring for:
    PHP Api Version:         20131106
    Zend Module Api No:      20131226
    Zend Extension Api No:   220131226
    shtool at '/tmp/pear/temp/geoip/build/shtool' does not exist or is not executable.
    Make sure that the file exists and is executable and then rerun this script.
    
    ERROR: `phpize' failed
    I suppose it's simple to solve, but...

  4. #4
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,060
    PECL in certain cases might not work on DA servers:

    - /tmp mounted with noexec
    - Mulitple instances of PHP installed.

    So use phpize instead with full paths:


    Code:
    cd <DIR>
    /usr/local/php56/bin/phpize
    ./configure --with-php-config=/usr/local/php56/bin/php-config
    make && make install
    Regards, Alex G.

    - You can hire me on www.poralix.com to work on your server
    - Follow and like @Poralix on Facebook

  5. #5
    Join Date
    Dec 2008
    Posts
    518
    And with the other method :


    Code:
    ]# cd /usr/share/doc/php-pecl-geoip-1.0.8
    # phpize
    Cannot find config.m4.
    Make sure that you run '/usr/local/bin/phpize' in the top level source directory of the module

    And the message does not help me

  6. #6
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,060
    see post #4
    Regards, Alex G.

    - You can hire me on www.poralix.com to work on your server
    - Follow and like @Poralix on Facebook

  7. #7
    Join Date
    Dec 2008
    Posts
    518
    Thanks, but same problem

    Code:
     /usr/local/php56/bin/phpize
    Cannot find config.m4.
    Make sure that you run '/usr/local/php56/bin/phpize' in the top level source directory of the module

  8. #8
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,060
    Correct name for the PECL extension for PHP is geoip. You downloaded something else different.
    Regards, Alex G.

    - You can hire me on www.poralix.com to work on your server
    - Follow and like @Poralix on Facebook

  9. #9
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,060
    Here is what I have on CentOS:

    Code:
    yum -y install GeoIP-devel
    and general instructions:

    Code:
    export PHP_VER=56
    export PECL_EXT=geoip
    cd /usr/local/src
    /usr/local/php${PHP_VER}/bin/pecl download ${PECL_EXT}
    tar -zxvf ${PECL_EXT}-*.tgz && cd ${PECL_EXT}-*/
    /usr/local/php${PHP_VER}/bin/phpize
    ./configure --with-php-config=/usr/local/php${PHP_VER}/bin/php-config
    make && make install
    echo "extension=${PECL_EXT}.so" >> /usr/local/php${PHP_VER}/lib/php.conf.d/90-custom.ini
    Full version: https://help.poralix.com/articles/in...ctadmin-server

    Regards,
    Alex.

  10. #10
    Join Date
    Feb 2017
    Posts
    13
    You can try to change the tmp directory

    Code:
    mkdir /opt/tmp 
    pecl config-set temp_dir /opt/tmp && pear config-set temp_dir /opt/tmp
    
    pecl install geoip

  11. #11
    Join Date
    Dec 2008
    Posts
    518
    Many thanks zEitEr !!!
    It works !

    Thanks too RoseHosting, I don't try your solution.


    Another problem if you can help me.... : https://forum.directadmin.com/showthread.php?t=54546

  12. #12
    Join Date
    Dec 2008
    Posts
    518
    Quote Originally Posted by zEitEr View Post
    Here is what I have on CentOS:
    Alex.
    Hi
    For php 7.1, it doesn't work, because geoip 1.0.8 send errors.
    I see it's ok with beta version 1.1.1.

    So, I do replace your line
    /usr/local/php${PHP_VER}/bin/pecl download ${PECL_EXT}
    by
    wget https://pecl.php.net/get/geoip-1.1.1.tgz


    And it works perfectly ! Thanks a new time !

    And for those searching long time.... do not forget to restart php71 (service httpd restart is not enough !!)

  13. #13
    Join Date
    Dec 2008
    Posts
    518
    Hi

    I've a new problem with PHP 7.3 and geoip


    # php -v
    PHP Warning: PHP Startup: geoip: Unable to initialize module
    Module compiled with module API=20170718
    PHP compiled with module API=20180731


    Installation write with 20180731 !!
    So, I don't understand.


    Here my installation :

    Code:
    [root@myhost108 ~]# export PHP_VER=73
    [root@myhost108 ~]# export PECL_EXT=geoip
    [root@myhost108 ~]# cd /usr/local/src
    [root@myhost108 src]# wget https://pecl.php.net/get/geoip-1.1.1.tgz 
    [root@myhost108 src]# tar -zxvf ${PECL_EXT}-*.tgz && cd ${PECL_EXT}-*/
    [root@myhost108 geoip-1.1.1]# /usr/local/php${PHP_VER}/bin/phpize
    Configuring for:
    PHP Api Version:         20180731
    Zend Module Api No:      20180731
    Zend Extension Api No:   320180731
    [root@myhost108 geoip-1.1.1]# ./configure --with-php-config=/usr/local/php${PHP_VER}/bin/php-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 whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    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-pc-linux-gnu
    checking host system type... x86_64-pc-linux-gnu
    checking target system type... x86_64-pc-linux-gnu
    checking for PHP prefix... /usr/local/php73
    checking for PHP includes... -I/usr/local/php73/include/php -I/usr/local/php73/include/php/main -I/usr/local/php73/include/php/TSRM -I/usr/local/php73/include/php/Zend -I/usr/local/php73/include/php/ext -I/usr/local/php73/include/php/ext/date/lib
    checking for PHP extension directory... /usr/local/php73/lib/php/extensions/no-debug-non-zts-20180731
    checking for PHP installed headers prefix... /usr/local/php73/include/php
    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... found in /usr
    checking for GeoIP_open in -lGeoIP... yes
    checking for GeoIP_setup_custom_directory in -lGeoIP... yes
    checking for GeoIP_set_charset in -lGeoIP... yes
    checking for GeoIP_continent_by_id in -lGeoIP... yes
    checking for GeoIP_addr_to_num in -lGeoIP... yes
    checking whether GEOIP_NETSPEED_EDITION_REV1 is declared... yes
    checking whether GEOIP_ACCURACYRADIUS_EDITION is declared... yes
    checking for LGPL compatible GeoIP libs... expr: non-integer argument
    cannot detect
    checking library features to determine version (not acurate)... found 1005000
    checking for ld used by cc... /bin/ld
    checking if the linker (/bin/ld) is GNU ld... yes
    checking for /bin/ld option to reload object files... -r
    checking for BSD-compatible nm... /bin/nm -B
    checking whether ln -s works... yes
    checking how to recognize dependent libraries... pass_all
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking dlfcn.h usability... yes
    checking dlfcn.h presence... yes
    checking for dlfcn.h... yes
    checking the maximum length of command line arguments... 1572864
    checking command to parse /bin/nm -B output from cc object... ok
    checking for objdir... .libs
    checking for ar... ar
    checking for ranlib... ranlib
    checking for strip... strip
    checking if cc supports -fno-rtti -fno-exceptions... no
    checking for cc option to produce PIC... -fPIC
    checking if cc PIC flag -fPIC works... yes
    checking if cc static flag -static works... no
    checking if cc supports -c -o file.o... yes
    checking whether the cc linker (/bin/ld -m elf_x86_64) supports shared libraries... yes
    checking whether -lc should be explicitly linked in... no
    checking dynamic linker characteristics... GNU/Linux ld.so
    checking how to hardcode library paths into programs... immediate
    checking whether stripping libraries is possible... yes
    checking if libtool supports shared libraries... yes
    checking whether to build shared libraries... yes
    checking whether to build static libraries... no
    
    creating libtool
    appending configuration tag "CXX" to libtool
    configure: creating ./config.status
    config.status: creating config.h
    config.status: config.h is unchanged
    [root@myhost108 geoip-1.1.1]# make && make install
    /bin/sh /usr/local/src/geoip-1.1.1/libtool --mode=install cp ./geoip.la /usr/local/src/geoip-1.1.1/modules
    cp ./.libs/geoip.so /usr/local/src/geoip-1.1.1/modules/geoip.so
    cp ./.libs/geoip.lai /usr/local/src/geoip-1.1.1/modules/geoip.la
    PATH="$PATH:/sbin" ldconfig -n /usr/local/src/geoip-1.1.1/modules
    ----------------------------------------------------------------------
    Libraries have been installed in:
       /usr/local/src/geoip-1.1.1/modules
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    ----------------------------------------------------------------------
    
    Build complete.
    Don't forget to run 'make test'.
    
    Installing shared extensions:     /usr/local/php73/lib/php/extensions/no-debug-non-zts-20180731/
    [root@myhost108 geoip-1.1.1]# service httpd restart
    Redirecting to /bin/systemctl restart httpd.service
    [root@myhost108 geoip-1.1.1]# php -v
    PHP Warning:  PHP Startup: geoip: Unable to initialize module
    Module compiled with module API=20170718
    PHP    compiled with module API=20180731
    These options need to match
     in Unknown on line 0
    PHP 7.3.0 (cli) (built: Dec  8 2018 22:52:30) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.3.0, Copyright (c) 1999-2018, by Zend Technologies

    Do you have an idea ?
    Thanks

  14. #14
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,060
    What do you see with

    Code:
    /usr/local/php73/bin/php -i | grep extension_dir
    ?
    Regards, Alex G.

    - You can hire me on www.poralix.com to work on your server
    - Follow and like @Poralix on Facebook

  15. #15
    Join Date
    Dec 2008
    Posts
    518
    Thanks zEitEr



    Code:
    # /usr/local/php73/bin/php -i | grep extension_dir
    PHP Warning:  PHP Startup: geoip: Unable to initialize module
    Module compiled with module API=20170718
    PHP    compiled with module API=20180731
    These options need to match
     in Unknown on line 0
    extension_dir => /usr/local/php73/lib/php/extensions/no-debug-non-zts-20180731 => /usr/local/php73/lib/php/extensions/no-debug-non-zts-20180731
    sqlite3.extension_dir => no value => no value

  16. #16
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,060
    And
    Code:
    grep geoip.so /usr/local/php73/lib/php.conf.d/*.ini
    ?
    Regards, Alex G.

    - You can hire me on www.poralix.com to work on your server
    - Follow and like @Poralix on Facebook

  17. #17
    Join Date
    Dec 2008
    Posts
    518
    Code:
    # grep geoip.so /usr/local/php73/lib/php.conf.d/*.ini
    /usr/local/php73/lib/php.conf.d/90-custom.ini:extension=/usr/local/php73/lib/php/extensions/no-debug-non-zts-20180731/geoip.so
    It was : extension=geoip.so
    I try with complete path, but same result.

  18. #18
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,060
    I tried on my own and it succeeded.

    What you get?

    Code:
    find /usr/local/php*/ -name geoip.so -exec ls -la {} \;
    Code:
    grep geoip.so /usr/local/php73/lib/php.ini
    Regards, Alex G.

    - You can hire me on www.poralix.com to work on your server
    - Follow and like @Poralix on Facebook

  19. #19
    Join Date
    Dec 2008
    Posts
    518
    Hi zEitEr

    Code:
    # find /usr/local/php*/ -name geoip.so -exec ls -la {} \;
    -rwxr-xr-x 1 root root 83608 Dec 11 23:51 /usr/local/php73/lib/php/extensions/no-debug-non-zts-20180731/geoip.so
    Code:
    # grep geoip.so /usr/local/php73/lib/php.conf.d/*.ini
    /usr/local/php73/lib/php.conf.d/90-custom.ini:extension=geoip.so

  20. #20
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,060
    The last grep command differs, please check it against /usr/local/php73/lib/php.ini

    I wonder if you try to load geoip.so somewhere else.

    And if you remove extension= with geoip.so from /usr/local/php73/lib/php.conf.d/90-custom.ini will you still have the error.
    Last edited by zEitEr; 12-12-2018 at 04:51 AM.
    Regards, Alex G.

    - You can hire me on www.poralix.com to work on your server
    - Follow and like @Poralix on Facebook

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •