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

Amit Dube picture Amit Dube · Jan 29, 2019 · Viewed 20.7k times · Source

I am trying to build Apache Server v 2.4.38 on RHEL 7.3 and I am using apr 1.6.5, apr-util 1.6.1, and pcre 8.42.

I am running following commands

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

make

While running 'make' I am receiving error

/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>

Answer

Amit Dube picture Amit Dube · Jan 29, 2019

Download expat-2.2.6.tar.bz2 from https://libexpat.github.io/.

Extract expat using following command

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

Change to the extracted expat directory.

Build expat using following commands

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

  2. make

  3. make install

While building Apache Httpd from source specify --with-expat

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