{"id":21945939,"url":"https://github.com/ip2location/ip2location-apache","last_synced_at":"2025-04-22T21:27:58.798Z","repository":{"id":69650818,"uuid":"78708933","full_name":"ip2location/ip2location-apache","owner":"ip2location","description":"This is a IP2Location Apache Module that enables the user to find the country, region, city, latitude, longitude, zip code, time zone, ISP, domain name, connection type, area code, weather, mobile network, elevation, usage type, address type and IAB category by IP address or hostname originates from.","archived":false,"fork":false,"pushed_at":"2024-01-03T05:24:49.000Z","size":38,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-18T21:16:49.122Z","etag":null,"topics":["apache","geolocation","ip-address-geolocation","ip-database","ip-geolocation","ip-lookup","ip2location","ip2location-apache"],"latest_commit_sha":null,"homepage":"http://www.ip2location.com","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ip2location.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-12T04:36:15.000Z","updated_at":"2024-01-26T16:49:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"febd669d-364f-4a01-ae4c-06622770bac9","html_url":"https://github.com/ip2location/ip2location-apache","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-apache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-apache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-apache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-apache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ip2location","download_url":"https://codeload.github.com/ip2location/ip2location-apache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250327319,"owners_count":21412403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache","geolocation","ip-address-geolocation","ip-database","ip-geolocation","ip-lookup","ip2location","ip2location-apache"],"created_at":"2024-11-29T04:20:29.955Z","updated_at":"2025-04-22T21:27:58.779Z","avatar_url":"https://github.com/ip2location.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IP2Location Apache Module\n\nThis is a IP2Location Apache Module that enables the user to find the country, region or state, district, city, latitude and longitude,  ZIP/Postal code, time zone, Internet Service Provider (ISP) or company  name, domain name, net speed, area code, weather station code, weather  station name, mobile country code (MCC), mobile network code (MNC) and  carrier brand, elevation, usage type, address type, IAB category and ASN and category by IP address or hostname originates from. The library reads the geo location information\nfrom **IP2Location BIN data** file.\n\nSupported IPv4 and IPv6 address.\n\nFor more details, please visit:\n[https://www.ip2location.com/developers/apache](https://www.ip2location.com/developers/apache)\n\n# Requirements\n1. IP2Location C API library (download from https://github.com/chrislim2888/IP2Location-C-Library)\n2. Apache 2.0x\n3. GNU make or any compatible make utility.\n\n# Installation\n### Linux Build (Debian)\n1. Create a new folder called ip2location.\n\n2. Install the development libraries in Debian.\n   ```\n   apt install apache2-dev\n   ```\n\n3. Download IP2Location C library from [here](https://github.com/chrislim2888/IP2Location-C-Library/archive/master.zip) into the ip2location folder.\n\n4. Decompress C library.\n\n   ```\n   unzip master.zip \u0026\u0026 rm master.zip\n   ```\n\n5. Get into working directory.\n\n   ```\n   cd IP2Location-C-Library-master\n   ```\n\n6. Compile and install IP2Location-C-Library.\n\n   ```\n   autoreconf -i -v --force\n   ./configure\n   make\n   make install\n   ```\n   Note: You may need to run ```ldconfig``` to refresh the shared libraries, if needed.\n\n7. Download [IP2Location Apache Module](https://github.com/ip2location/ip2location-apache/archive/refs/heads/master.zip) into the ip2location folder.\n\n8. Decompress IP2Location Apache Module\n\n   ```\n   unzip master.zip \u0026\u0026 rm master.zip\n   ```\n\n9. Get into IP2Location Apache Module directory.\n\n   ```\n   cd ip2location-apache-master\n   ```\n\n10. Compile the IP2Location Apache Module.\n\n   ```\n   apxs2 -i -a -L ../IP2Location-C-Library-master/libIP2Location/ -I ../IP2Location-C-Library-master/libIP2Location/ -l IP2Location -c mod_ip2location.c\n   ```\n\n12. Run the below command and make sure you see **IP2Location_module (shared)** entry.\n\n   ```\n   apache2ctl -M\n   ```\n\n13. Add following lines into **/etc/apache2/apache2.conf**\n\n   ```\n   \u003cIfModule mod_ip2location.c\u003e\n   \tIP2LocationEnable On\n   \tIP2LocationDetectProxy \u003cOn|Off\u003e\n   \tIP2LocationSetmode ALL\n   \tIP2LocationDBFile \u003cip2location_binary_db_file_with_fully_qualified_path\u003e\n   \u003c/IfModule\u003e\n   ```\n\n\n\n### Windows Build\n\n1. Create a new folder called ip2location.\n\n2. Download IP2Location C library from [here](https://github.com/chrislim2888/IP2Location-C-Library/archive/master.zip) into the ip2location folder.\n\n3. Decompress C library using [7-zip](https://www.7-zip.org/) or other compression tools.\n\n4. Get into working directory.\n\n   ```\n   cd IP2Location-C-Library-master\n   ```\n\n5. Start compilation.\n\n   ```\n   nmake /f Makefile.win\n   ```\n\n6. Download and decompress Apache module into the ip2location folder.\n\n7. Navigate to ip2location-apache-master folder.\n\n8. Edit Makefile.win to change the path for C library.\n\n   ```\n   IP2LOCATION_CSRC_PATH = C:/ip2location/IP2Location-C-Library-master/libIP2Location\n   IP2LOCATION_CLIB_PATH = C:/ip2location/IP2Location-C-Library-master/libIP2Location\n   APACHE_INSTALL_PATH = \"C:/Program Files/Apache Software Foundation/Apachex.x\"\n   ```\n\n9. Start compilation.\n\n   ```\n   nmake /f Makefile.win\n   ```\n\n10. Copy IP2Location_apache.dll generated to the Apache modules directory.\n\n11. Add following lines into httpd.conf\n\n    ```\n    \u003cIfModule mod_ip2location.c\u003e\n    \tIP2LocationEnable \u003cON|OFF\u003e\n    \tIP2LocationDetectProxy \u003cON|OFF\u003e\n    \tIP2LocationSetmode ALL\n    \tIP2LocationDBFile \u003cip2location_binary_db_file_with_fully_qualified_path\u003e\n    \u003c/IfModule\u003e\n    ```\n\n\n\n# Apache Configuration\n\n1. To load IP2Location module in Apache,  add the following lines in httpd.conf.\n\n    ```\n    LoadModule IP2Location_module FULL_PATH_TO_IP2LOCATION_MODULE\n    \n    \u003cIfModule mod_ip2location.c\u003e\n    IP2LocationEnable On \n    # ENV will set server variables\n    # NOTES will set apache notes \n    # ALL will set both\n    IP2LocationSetmode ALL\n    IP2LocationDBFile PATH_TO_IP2LOCATION_BIN_DATABASE\n    IP2LocationDetectProxy On\n    \u003c/IfModule\u003e\n    ```\n\n    \n\n    Reference:\n\n    | Name                   | Value           | Description                                                  |\n    | ---------------------- | --------------- | ------------------------------------------------------------ |\n    | IP2LocationEnable      | On\\|Off         | Enable or disable IP2Location module.                        |\n    | IP2LocationSetmode     | ENV\\|NOTES\\|ALL | Choose where to display the geolocation variables. ENV = Server variables, NOTES = Apache notes, ALL = Both |\n    | IP2LocationDBFile      | Path            | The full path to a IP2Location BIN database                  |\n    | IP2LocationDetectProxy | On\\|Off         | If you website is hosted behind a reverse proxy server, turn this on to detect the correct IP address |\n\n    \n\n2. Restart Apache server to take effect of the changes\n\n**Notes**\nIf you are getting startup errors where Apache cannot locate the module files, please set your environment path as below:\n\n```\n$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/apache2/modules/\n$ export LD_LIBRARY_PATH\n```\n\n# Testing\n### PHP Testing\nFrom internet browser, load mod_ip2location_test.php\n\n### Apache Rewrite Testing\n1. Add below lines to your domain configuration file (apaches/sites-enabled) or .htaccess:  \n   \n    ```\n    RewriteEngine On\n    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^US$\n    RewriteRule ^(.*)$ https://www.google.com [L]\n    ```\n    \n2. This will redirect all IP address from United States to https://www.google.com\n\n\n# Sample BIN Databases\n* Download free IP2Location LITE databases at [https://lite.ip2location.com](https://lite.ip2location.com)  \n* Download IP2Location sample databases at [https://www.ip2location.com/developers](https://www.ip2location.com/developers)\n\n# IPv4 BIN vs IPv6 BIN\n* Use the IPv4 BIN file if you just need to query IPv4 addresses.\n* Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.\n\n# Support\nEmail: support@ip2location.com.  \nURL: [https://www.ip2location.com](https://www.ip2location.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-apache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fip2location%2Fip2location-apache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-apache/lists"}