下载 GeoLite2-Country.mmdb 文件主要有两种方式:从 MaxMind 官方下载(需要注册) 或使用第三方 CDN 镜像(无需注册,更快捷)
下载 GeoLite2-Country.mmdb 文件主要有两种方式:从 MaxMind 官方下载(需要注册)或使用第三方 CDN 镜像(无需注册,更快捷)。
🚀 快速方案:使用 CDN 镜像(推荐)
如果你不想注册账号,可以使用以下任一镜像链接直接下载:
方法一:使用 jsDelivr CDN(速度较快)
# 创建目录并下载sudomkdir-p/www/server/nginx/conf/geoipcd/www/server/nginx/conf/geoipsudowget-OGeoLite2-Country.mmdb.gz https://cdn.jsdelivr.net/npm/geolite2-country@1.0.6/GeoLite2-Country.mmdb.gzsudogunzip GeoLite2-Country.mmdb.gz该数据库文件来自 npm 包
geolite2-country,版本为 1.0.6。下载后为.gz压缩格式,需要用gunzip解压。
方法二:使用 GitCode 镜像
cd/www/server/nginx/conf/geoipsudowget-OGeoLite2-Country.mmdb https://gitcode.com/open-source-toolkit/94ce3/raw/main/GeoLite2-Country.mmdb该镜像来自 GitCode 开源仓库,数据库约为 3.7MB,精确到国家级别。
🔐 官方方案:从 MaxMind 下载(需要注册)
如果你希望使用官方最新版本,可以注册 MaxMind 账号后下载:
- 注册账号:访问 MaxMind 官网 注册免费账户
- 获取许可证密钥:登录后在 Account Settings 中生成 License Key
- 下载数据库:
cd/www/server/nginx/conf/geoip# 替换 YOUR_LICENSE_KEY 为实际的密钥wget-OGeoLite2-Country.tar.gz"https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=YOUR_LICENSE_KEY&suffix=tar.gz"tar-xzfGeoLite2-Country.tar.gz# 移动文件到正确位置sudomvGeoLite2-Country_*/GeoLite2-Country.mmdb ./sudorm-rfGeoLite2-Country_* GeoLite2-Country.tar.gz注意:自 2019 年 12 月 30 日起,MaxMind 已禁止直接通过
wget下载免费数据库,必须使用许可证密钥。
✅ 下载完成后的配置步骤
无论使用哪种方式下载,完成后都需要:
# 1. 设置正确的权限(宝塔面板用 www 用户)sudochmod644/www/server/nginx/conf/geoip/GeoLite2-Country.mmdbsudochownwww:www /www/server/nginx/conf/geoip/GeoLite2-Country.mmdb# 2. 测试 Nginx 配置nginx-t# 3. 重载 Nginxnginx-sreload# 或systemctl reload nginx📋 文件说明
| 属性 | 说明 |
|---|---|
| 文件格式 | .mmdb(GeoIP2 Binary 格式) |
| 数据库类型 | GeoLite2 Country(国家级别) |
| 文件大小 | 约 3.7 MB |
| 更新频率 | 官方每周二更新 |
| 许可证 | CC BY-SA 4.0,使用时需注明来源 MaxMind |
推荐先尝试方法一(jsDelivr CDN),速度较快且无需注册。如果下载过程中遇到问题,请告诉我具体的错误信息。
