CentOS环境下Nginx源码编译安装产生错误缺失GD库的问题解决 centos6 宝塔面板安装nginx报错 缺少GD library环境依赖包


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


./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.12

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

实际上,该模块也可以去官网获取文件然后进行源码编译
但这里,我们一切从简, CentOS 环境 解决如下 :输入yum search GD 查看安装包,然后输入 sudo yum install -y gd-devel.x86_64

[centos@localhost nginx-1.16.1]$ :<<!
 先用 yum 查找 'GD' 库,知道存在包 `gd-devel.x86_64` 需要安装![centos@localhost nginx-1.16.1]$ yum search GD
已加载插件: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: GD =============================================compat-libgdata13.i686 : Compat package with libgdata 0.13 libraries
compat-libgdata13.x86_64 : Compat package with libgdata 0.13 libraries
gd-devel.i686 : The development libraries and header files for gd
gd-devel.x86_64 : The development libraries and header files for gd
gd-progs.x86_64 : Utility programs that use libgd
gdb-doc.noarch : Documentation for GDB (the GNU source-level debugger)gdb-gdbserver.x86_64 : A standalone server for GDB (the GNU source-level debugger)gdbm-devel.i686 : Development libraries and header files for the gdbm library
gdbm-devel.x86_64 : Development libraries and header files for the gdbm library
gdk-pixbuf2-devel.i686 : Development files for gdk-pixbuf
gdk-pixbuf2-devel.x86_64 : Development files for gdk-pixbuf
gdk-pixbuf2-tests.x86_64 : Tests for the gdk-pixbuf2 package
gdm-devel.i686 : Development files for gdm
gdm-devel.x86_64 : Development files for gdm
gdm-pam-extensions-devel.i686 : Macros for developing GDM extensions to PAM
gdm-pam-extensions-devel.x86_64 : Macros for developing GDM extensions to PAM
graphviz-gd.i686 : Graphviz plugin for renderers based on gd
graphviz-gd.x86_64 : Graphviz plugin for renderers based on gd
gupnp-igd.i686 : Library to handle UPnP IGD port mapping
gupnp-igd.x86_64 : Library to handle UPnP IGD port mapping
gupnp-igd-devel.i686 : Development files for gupnp-igd
gupnp-igd-devel.x86_64 : Development files for gupnp-igd
gupnp-igd-python.x86_64 : Python bindings for gupnp-igd
libgdata.i686 : Library for the GData protocol
libgdata.x86_64 : Library for the GData protocol
libgdata-devel.i686 : Development files for libgdata
libgdata-devel.x86_64 : Development files for libgdata
libgdither-devel.i686 : Development files for libgdither
libgdither-devel.x86_64 : Development files for libgdither
libreoffice-gdb-debug-support.x86_64 : Additional support for debugging with gdb
perl-GD.x86_64 : Perl interface to the GD graphics library
perl-GD-Barcode.noarch : Create barcode image with GD
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php55w-gd.x86_64 : A module for PHP applications for using the gd graphics library
php56w-gd.x86_64 : A module for PHP applications for using the gd graphics library
php70w-gd.x86_64 : A module for PHP applications for using the gd graphics library
php71w-gd.x86_64 : A module for PHP applications for using the gd graphics library
php72w-gd.x86_64 : A module for PHP applications for using the gd graphics library
pulseaudio-gdm-hooks.x86_64 : PulseAudio GDM integration
relaxngDatatype-javadoc.noarch : API documentation for relaxngDatatype
rubygem-bigdecimal.x86_64 : BigDecimal provides arbitrary-precision floating point decimal arithmetic
cgdcbxd.x86_64 : DCB network priority management daemon
gd.i686 : A graphics library for quick creation of PNG or JPEG images
gd.x86_64 : A graphics library for quick creation of PNG or JPEG images
gdb.x86_64 : A GNU source-level debugger for C, C++, Fortran, Go and other languages
gdbm.i686 : A GNU set of database routines which use extensible hashing
gdbm.x86_64 : A GNU set of database routines which use extensible hashing
gdisk.x86_64 : An fdisk-like partitioning tool for GPT disks
gdk-pixbuf2.i686 : An image loading library
gdk-pixbuf2.x86_64 : An image loading library
gdm.i686 : The GNOME Display Manager
gdm.x86_64 : The GNOME Display Manager
hunspell-gd.noarch : Scots Gaelic hunspell dictionaries
libgdither.i686 : Library for applying dithering to PCM audio sources
libgdither.x86_64 : Library for applying dithering to PCM audio sources
relaxngDatatype.noarch : RELAX NG Datatype API
swig3-gdb.x86_64 : Commands for easier debugging of SWIG

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

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

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

实际上, GD 库是许多软件必备的依赖库,不一定是 nginx 。


发表评论 已发布 0

还可以输入 800 个字
看不清?点击更换
 
 
评论 打印