GeoIP bei php 7.4 hinzufügen

Diskussionen zur Bedienung von KeyHelp.
Post Reply
pvonpidoll
Posts: 6
Joined: Sat 24. May 2025, 22:48

GeoIP bei php 7.4 hinzufügen

Post by pvonpidoll »

Hi,

Server-Betriebssystem + Version
Debian 12.11 (64-bit)
Eingesetzte Server-Virtualisierung-Technologie
KVM
KeyHelp-Version + Build-Nummer
25.0 (Build 3398)

Ich würde gerne wissen wie ich bei Keyhelp zu PHP 7.4 oder anderen PHP Versionen GeoIP hinzufügen kann.

Mit dem Standardbefehel (so wie ich es über andere Panels installiert habe):

Code: Select all

apt -y install php7.4-geoip
Bekomme ich folgenden Fehler über SSH:

Code: Select all

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package php7.4-geoip
E: Couldn't find any package by glob 'php7.4-geoip'
Könnt ihr mir helfen wie ich geoip installiert bekomme?
Ich bräuchte das für mein Gameserver Webinterface.

Hier im Forum und bei der Google Befragung habe ich nichts gefunden wie ich geoip bei Keyhelp installiert bekomme.
Freundliche Grüße
Pascal
User avatar
Fezzi
Posts: 253
Joined: Wed 12. Dec 2018, 04:04

Re: GeoIP bei php 7.4 hinzufügen

Post by Fezzi »

Nur mal schnell aus der Huefte geschossen,

Debian 12.11 laeuft mit PHP 8.2.28....

Ich nehme an das da der Hase begraben liegt...

https://github.com/rlerdorf/geoip

Hier mal auf die schnelle Gegoogelt:
To install and configure GeoIP in Debian 12.11 for use with PHP 8.2, you'll need to install the GeoIP library, its development files, and a GeoIP database, then configure your PHP installation to load the GeoIP extension. You'll also need to ensure you have the necessary PHP development packages installed.
1. Install the GeoIP library and development files:
Code

sudo apt update
sudo apt install libgeoip-dev geoip-database

2. Install the MaxMind-DB-Reader-php extension:
This extension allows you to work with MaxMind GeoIP databases (e.g., GeoLite2).
Code

sudo apt install php8.2-dev php8.2-mbstring
sudo apt install php8.2-zip
sudo apt install php8.2-xml
sudo apt install php8.2-curl
sudo apt install php8.2-gd
sudo apt install php8.2-ldap
sudo apt install php8.2-mysql
sudo apt install php8.2-redis
sudo apt install php8.2-readline
sudo apt install php8.2-sqlite
sudo apt install php8.2-snmp
sudo apt install php8.2-soap

3. Download or Checkout MaxMind-DB-Reader-php:
Code

git clone https://github.com/maxmind/MaxMind-DB-Reader-php.git
cd MaxMind-DB-Reader-php
./build.sh

4. Configure PHP to load the GeoIP extension:
Code

echo "extension=geoip.so" > /etc/php/8.2/mods-available/geoip.ini
sudo php8.2-fpm -t
sudo php8.2-fpm -i
sudo service php8.2-fpm restart
sudo service apache2 restart

5. Test GeoIP installation:
Create a PHP file (e.g., geoip_test.php) with the following code:
Code

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$geo_info = geoip_country_code_by_addr($ip);
if ($geo_info) {
echo "Country Code: " . $geo_info . "<br>";
} else {
echo "GeoIP lookup failed.";
}
?>

Access this file in your web browser to verify GeoIP is working correctly.
Important Notes:

PHP Version:
The commands are tailored for PHP 8.2. Adjust the package names accordingly if you're using a different version.

Web Server:
This guide assumes Apache. If you're using Nginx, you'll need to adjust the PHP-FPM configuration accordingly.
GeoIP Database:
You'll need to download and install a GeoIP database (e.g., GeoLite2) from MaxMind.
PHP Extension:
Ensure the geoip.so extension is loaded in your PHP configuration.
Testing:
The test file will display the country code based on your IP address. If it's not working, double-check your installation steps and configuration.

This comprehensive guide should help you get GeoIP running with PHP 8.2 on Debian 12.11. Remember to consult the official documentation for the most up-to-date instructions and troubleshooting tips.
Gruss

Fezzi

Everyone can do something, no one can do everything.
pvonpidoll
Posts: 6
Joined: Sat 24. May 2025, 22:48

Re: GeoIP bei php 7.4 hinzufügen

Post by pvonpidoll »

Danke für die Anleitung aber das Problem ist wirklich der dass das Webinterface nur unter PHP 7.4 läuft.
Ich brauche also wirklich für die PHP 7.4 das Geoip.

Gibt es die Möglichkeit das nachzuinstallieren für 7.4?
PHP8.2 bringt mir leider nichts bei dem Webinterface.

Image
Freundliche Grüße
Pascal
User avatar
24unix
Posts: 2037
Joined: Sun 21. Jun 2020, 17:16
Location: Kollmar
Contact:

Re: GeoIP bei php 7.4 hinzufügen

Post by 24unix »

pvonpidoll wrote: Sun 25. May 2025, 15:39 Danke für die Anleitung aber das Problem ist wirklich der dass das Webinterface nur unter PHP 7.4 läuft.
Ich brauche also wirklich für die PHP 7.4 das Geoip.
Das solltest Du überdenken, das slide habe ich vor über einem Jahr gemacht, mittlerweile wäre selbst 8.2 orange.

SCR-20250525-pktz.png
Du kannst es via pecl probieren, aber ich würde 7.4 nicht auf einem produktivem System einsetzen.
Cheers Micha
--
A Windows user reinstalls software every few weeks.
A Linux user reinstalls software every few weeks.
The difference is with Linux the version numbers change.
User avatar
Florian
Keyweb AG
Posts: 1682
Joined: Wed 20. Jan 2016, 02:28

Re: GeoIP bei php 7.4 hinzufügen

Post by Florian »

Hallo,

wen du das Modul für eine Keyhelp PHP Version brauchst musst du es selber bauen.

Anleitung am Beispiel Redis hier:

viewtopic.php?p=40585#p40585
Mit freundlichen Grüßen / Best regards
Florian Cheno

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
pvonpidoll
Posts: 6
Joined: Sat 24. May 2025, 22:48

Re: GeoIP bei php 7.4 hinzufügen

Post by pvonpidoll »

24unix wrote: Sun 25. May 2025, 17:43
pvonpidoll wrote: Sun 25. May 2025, 15:39 Danke für die Anleitung aber das Problem ist wirklich der dass das Webinterface nur unter PHP 7.4 läuft.
Ich brauche also wirklich für die PHP 7.4 das Geoip.
Das solltest Du überdenken, das slide habe ich vor über einem Jahr gemacht, mittlerweile wäre selbst 8.2 orange.


SCR-20250525-pktz.png

Du kannst es via pecl probieren, aber ich würde 7.4 nicht auf einem produktivem System einsetzen.
Danke 24unix für deine Antwort.
Bin hier schon im Austausch mit dem Entwickler des Gameserverinterfaces und warte hier noch auf Rückmeldung, weil laut deren Seite sollte es bis PHP 8.3 kompatibel sein.

Florian wrote: Mon 26. May 2025, 10:37 Hallo,

wen du das Modul für eine Keyhelp PHP Version brauchst musst du es selber bauen.

Anleitung am Beispiel Redis hier:

viewtopic.php?p=40585#p40585

Vielen dank Florian. Ich habe das ganze jetzt versucht auszuführen.
Allerdings komme ich nur bis zum ./configure Befehl und dann bekomme ich folgenden Fehler:

Code: Select all

./configure --with-php-config=/opt/keyhelp/php/7.4/bin/php-config
-bash: ./configure: No such file or directory <-- diesen Fehler
Woran liegt das bzw. was mach ich falsch?

So sieht das ganze aus wie ich geoip zum Keyhelp PHP 7.4 Interpreter hinzufüge:

Code: Select all

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

tar xzf geoip-1.1.1.tgz

cd geoip-1.1.1/

/opt/keyhelp/php/7.4/bin/phpize (install autoconf if necessary)

./configure --with-php-config=/opt/keyhelp/php/7.4/bin/php-config
make
make install

echo "extension=geoip.so" > /opt/keyhelp/php/7.4/etc/conf.d/geoip.ini

/etc/init.d/keyhelp-php74-fpm restart
Das ist der Ordner Inhalt wrote: build config.m4 config.w32 geoip.def php_geoip.h run-tests.php
ChangeLog configure.ac geoip.c LICENSE README tests
Freundliche Grüße
Pascal
User avatar
Florian
Keyweb AG
Posts: 1682
Joined: Wed 20. Jan 2016, 02:28

Re: GeoIP bei php 7.4 hinzufügen

Post by Florian »

Hallo,

dann hast du phpize nicht ausgeführt. Erst danach gibt es configure
Mit freundlichen Grüßen / Best regards
Florian Cheno

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
pvonpidoll
Posts: 6
Joined: Sat 24. May 2025, 22:48

Re: GeoIP bei php 7.4 hinzufügen

Post by pvonpidoll »

Florian wrote: Mon 26. May 2025, 15:24 Hallo,

dann hast du phpize nicht ausgeführt. Erst danach gibt es configure
phpize wurde ausgeführt allerdings war autoconf nicht installiert.
Jetzt ist autoconf installiert und ich bekomme beim ausführen vom configure Befehl folgende Meldung

Code: Select all

./configure --with-php-config=/opt/keyhelp/php/7.4/bin/php-config
make
make install
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... no
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 the compiler supports GNU C... yes
checking whether cc accepts -g... yes
checking for cc option to enable C11 features... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -R... 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... /opt/keyhelp/php/7.4
checking for PHP includes... -I/opt/keyhelp/php/7.4/include/php -I/opt/keyhelp/php/7.4/include/php/main -I/opt/keyhelp/php/7.4/include/php/TSRM -I/opt/keyhelp/php/7.4/include/php/Zend -I/opt/keyhelp/php/7.4/include/php/ext -I/opt/keyhelp/php/7.4/include/php/ext/date/lib
checking for PHP extension directory... /opt/keyhelp/php/7.4/lib/php/extensions/no-debug-non-zts-20190902
checking for PHP installed headers prefix... /opt/keyhelp/php/7.4/include/php
checking if debug is enabled... no
checking if zts is enabled... no
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
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target 'install'.  Stop.
Was fehlt hier jetzt?
Freundliche Grüße
Pascal
User avatar
Florian
Keyweb AG
Posts: 1682
Joined: Wed 20. Jan 2016, 02:28

Re: GeoIP bei php 7.4 hinzufügen

Post by Florian »

Hallo,

installiere mal noch build-essential

Code: Select all

apt install build-essential
Mit freundlichen Grüßen / Best regards
Florian Cheno

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
pvonpidoll
Posts: 6
Joined: Sat 24. May 2025, 22:48

Re: GeoIP bei php 7.4 hinzufügen

Post by pvonpidoll »

Florian wrote: Mon 26. May 2025, 16:21 Hallo,

installiere mal noch build-essential

Code: Select all

apt install build-essential
Ist bereits bei installiert.

Code: Select all

apt install build-essential
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
build-essential is already the newest version (12.9).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Freundliche Grüße
Pascal
User avatar
Florian
Keyweb AG
Posts: 1682
Joined: Wed 20. Jan 2016, 02:28

Re: GeoIP bei php 7.4 hinzufügen

Post by Florian »

Hallo,

achso ja, der Fehler ist ja auch ein anderer. Du brachst noch die GeoIP Bibliotheken

Es war mal

Code: Select all

  apt-get install libgeoip-dev geoip-bin geoip-database
Kann sein, dass die Pakete jetzt anders heißen, musst du mal danach suchen.
Mit freundlichen Grüßen / Best regards
Florian Cheno

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
pvonpidoll
Posts: 6
Joined: Sat 24. May 2025, 22:48

Re: GeoIP bei php 7.4 hinzufügen

Post by pvonpidoll »

Florian wrote: Mon 26. May 2025, 16:47 Hallo,

achso ja, der Fehler ist ja auch ein anderer. Du brachst noch die GeoIP Bibliotheken

Es war mal

Code: Select all

  apt-get install libgeoip-dev geoip-bin geoip-database
Kann sein, dass die Pakete jetzt anders heißen, musst du mal danach suchen.
Vielen dank.
Jetzt konnte ich GeoIP kompilieren für den Interpreter von Keyhelp PHP 7.4.

Dein Befehl ist der richtige gewesen.

Das ist die Anleitung für den PHP 7.4 Interpreter von keyhelp:

Code: Select all

apt install autoconf (muss installiert sein)
apt install build-essential (muss installiert sein)
apt install libgeoip-dev geoip-bin geoip-database (muss für geoip installiert sein)

Install/kompilieren GeoIP Keyhelp PHP 7.4 Interpreter:

wget https://pecl.php.net/get/geoip-1.1.1.tgz
tar xzf geoip-1.1.1.tgz
cd geoip-1.1.1/
/opt/keyhelp/php/7.4/bin/phpize
./configure --with-php-config=/opt/keyhelp/php/7.4/bin/php-config
make && make install
echo "extension=geoip.so" > /opt/keyhelp/php/7.4/etc/conf.d/geoip.ini
/etc/init.d/keyhelp-php74-fpm restart
Image
Freundliche Grüße
Pascal
Post Reply