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

4

22

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>
Monarchal answered 29/1, 2019 at 2:4 Comment(4)
I cannot do 'yum install expat-devel' because it needs sudo access.Monarchal
Why are you building Apache from source if you don't have root access?!Loggins
I want to start httpd server in my machine. Is it possible to install Apache Httpd with rpm package without having root access?Monarchal
You cannot make it listen on port 80 unless you have root access, so, you'd only be able to make it work on a port like 8080 (usually, ports below 1024 are reserved).Loggins
M
23

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

Monarchal answered 29/1, 2019 at 3:21 Comment(0)
H
12

For anyone else coming across this:

OP had to do this because they didn't have sudo access. If you do, usually you don't need to download the source of expat manually; installing via package manager is way easier. Unless the software you are compiling requires a newer version of expat than your RPM repos provide.

So for the RHEL family of OSes you can just do sudo <dnf|yum> install expat expat-devel, then proceed with what you were compiling.

Healing answered 26/6, 2021 at 13:36 Comment(2)
And for Debian/Ubuntu family: apt install libexpat1-devAssurance
On SLES the package name is libexpat-devel - so I had to install it as "sudo zypper install libexpat-devel" - however that library seems to beget the error described in #43862622Cardwell
L
2

Do you have the expat library installed? (Because that's where the expat.h comes from.)

If you cannot install it globally to the system, I'm sure Apache's ./configure script must have an option to support a custom location for the library as well.

Loggins answered 29/1, 2019 at 2:13 Comment(2)
Is there a parameter to specify expat library path in ./configure?Monarchal
Try ./configure --help | fgrep expat?!Loggins
E
2

Tried In Ubuntu
apt install libexpat1-dev
For RHEL, I would suggest @cyqsimon's answer

Euell answered 21/7, 2022 at 6:22 Comment(1)
libexpat1-dev fix my problem on debianScandian

© 2022 - 2024 — McMap. All rights reserved.