Linux-CentOS环境下Nginx源码编译安装产生错误缺失libxml2/libxslt库的问题解决
在
nginx
源码编译安装时,可能会碰到以下错误:
./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.
很显然,错误提示非常明显,缺失 libxml2/libxslt
库,即使你不安装该模块也可以继续进行安装,但是后续使用可能会产生错误,这里应该进行解决,安装该模块即可。
实际上,该模块也可以去官网获取文件然后进行源码编译。
但这里,我们一切从简, CentOS 环境 解决如下 :
[centos@localhost nginx-1.16.1]$ :<<!
先用 yum 查找 'libxml2' 库,知道存在包 `libxml2-devel.x86_64` 需要安装
!
[centos@localhost nginx-1.16.1]$ yum search libxml2
已加载插件: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: libxml2 ===========================================
libxml2-python.x86_64 : Python bindings for the libxml2 library
libxml2-static.i686 : Static library for libxml2
libxml2-static.x86_64 : Static library for libxml2
libxml2.i686 : Library providing XML and HTML support
libxml2.x86_64 : Library providing XML and HTML support
libxml2-devel.i686 : Libraries, includes, etc. to develop XML and HTML applications
libxml2-devel.x86_64 : Libraries, includes, etc. to develop XML and HTML applications
perl-XML-LibXML.x86_64 : Perl interface to the libxml2 library
python-lxml.x86_64 : ElementTree-like Python bindings for libxml2 and libxslt
名称和简介匹配 only,使用“search all”试试。
[centos@localhost nginx-1.16.1]$ :<<!
先用 yum 查找 'libxslt' 库,知道存在包 `libxslt-devel.x86_64` 需要安装
!
[centos@localhost nginx-1.16.1]$ yum search libxslt
已加载插件: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: libxslt ===========================================
libxslt-devel.i686 : Development files for libxslt
libxslt-devel.x86_64 : Development files for libxslt
libxslt-python.x86_64 : Python bindings for the libxslt library
perl-XML-LibXSLT.x86_64 : Perl module for interfacing to GNOME's libxslt
libxslt.i686 : Library providing the Gnome XSLT engine
libxslt.x86_64 : Library providing the Gnome XSLT engine
python-lxml.x86_64 : ElementTree-like Python bindings for libxml2 and libxslt
名称和简介匹配 only,使用“search all”试试。
[centos@localhost nginx-1.16.1]$ # 安装 libxml2-devel.x86_64 库
[centos@localhost nginx-1.16.1]$ sudo yum install -y libxml2-devel.x86_64
[centos@localhost nginx-1.16.1]$ # 安装 libxslt-devel.x86_64 库
[centos@localhost nginx-1.16.1]$ sudo yum install -y libxslt-devel.x86_64
这样就解决了该问题,只需要重新编译 nginx 即可。
这里顺便补充一下,nginx 还可能报缺失其他库的错误。比如缺失 pcre
, zlib
, openssl
库等,这些缺失库的问题处理都大同小异。 除了去官方下载源码进行编译之外,也可以通过依赖包软件管理器进行对应的库安装。 我们这里采用的办法就是第二种,更简便。这样就可以解决这种问题。