Apache Httpd Build from source: fatal error: expat.h: No such file or directory

Apache Httpd Build from source: fatal error: expat.h: No such file or directory

我正在尝试在 RHEL 7.3 上构建 Apache Server v 2.4.38,我使用的是 apr 1.6.5、apr-util 1.6.1 和 pcre 8.42。

我运行 遵循命令

./configure  --with-included-apr --with-pcre=/data/abc/installed/pcre_installed --prefix=/data/abc/installed/httpd_installed  

make

虽然 运行 'make' 我收到错误消息

/bin/sh /data/abc/installed/httpd-2.4.38/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/data/abc/installed/httpd-2.4.38/srclib/apr-util/include -I/data/abc/installed/httpd-2.4.38/srclib/apr-util/include/private  -I/data/abc/installed/httpd-2.4.38/srclib/apr/include    -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
 #include <expat.h>

您是否安装了 expat 库? (因为那是 expat.h 的来源。)

如果您不能将它全局安装到系统,我相信 Apache 的 ./configure 脚本也必须有一个选项来支持库的自定义位置。

https://libexpat.github.io/.

下载 expat-2.2.6.tar.bz2

使用以下命令提取 expat

tar xvjf expat-2.2.6.tar.bz2 -C /path-to-dir

切换到提取的 expat 目录。

使用以下命令构建 expat

  1. ./configure --prefix=/path-to-expat-installation-dir

  2. 制作

  3. 进行安装

从源代码构建 Apache Httpd 时指定 --with-expat

./configure --with-included-apr --prefix=/path-to-apache-installation --with-expat=/path-to-expat-installation-dir

对于遇到此问题的任何其他人:

OP 不得不这样做,因为他们没有 sudo 访问权限。如果这样做,通常不需要手动下载 expat 的源代码;通过包管理器安装更容易。除非您正在编译的软件需要比您的 RPM 存储库提供的 expat 更新的版本。

因此,对于 RHEL 操作系统系列,您可以 sudo <dnf|yum> install expat expat-devel,然后继续您正在编译的内容。