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

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

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值