Linux-CentOS环境下Nginx源码编译安装产生错误缺失GeoIP库的问题解决


nginx 源码编译安装时,可能会碰到以下错误:

./configure: error: the GeoIP module requires the GeoIP library.
You can either do not enable the module or install the library.

很显然,错误提示非常明显,缺失 GeoIP 库,即使你不安装该模块也可以继续进行安装,但是后续使用可能会产生错误,这里应该进行解决,安装该模块即可。

实际上,该模块也可以去官网获取文件然后进行源码编译
但这里,我们一切从简, CentOS 环境 解决如下

[centos@localhost nginx-1.16.1]$ :<<!
 先用 yum 查找 'GeoIP' 库,知道存在包 `GeoIP-devel.x86_64` 需要安装
!
[centos@localhost nginx-1.16.1]$ yum search GeoIP
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
 * webtatic: us-east.repo.webtatic.com
=========================================== N/S matched: GeoIP ============================================
GeoIP-data.noarch : Static snapshot of GeoIP databases
GeoIP-devel.i686 : Development headers and libraries for GeoIP
GeoIP-devel.x86_64 : Development headers and libraries for GeoIP
geoipupdate.x86_64 : Update GeoIP2 and GeoIP Legacy binary databases from MaxMind
geoipupdate-cron.noarch : Cron job to do weekly updates of GeoIP databases
GeoIP.i686 : Library for country/city/organization to IP address or hostname mapping
GeoIP.x86_64 : Library for country/city/organization to IP address or hostname mapping
nginx1w-module-http-geoip.x86_64 : A module to provide variables with values depending on the client IP
                                 : address
php55w-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places
php56w-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places
php70w-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places
php71w-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places
php72w-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places

  名称和简介匹配 only,使用“search all”试试。
  
[centos@localhost nginx-1.16.1]$ # 安装 GeoIP-devel.x86_64 库
[centos@localhost nginx-1.16.1]$ sudo yum install -y GeoIP-devel.x86_64

这样就解决了该问题,只需要重新编译 nginx 即可。

这里顺便补充一下,nginx 还可能报缺失其他库的错误。比如缺失 pcrezlibopenssl 库等,这些缺失库的问题处理都大同小异。 除了去官方下载源码进行编译之外,也可以通过依赖包软件管理器进行对应的库安装。 我们这里采用的办法就是第二种,更简便。这样就可以解决这种问题。

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐