• Get application security done the right way! Detect, Protect, Monitor, Accelerate, and more…
  • Installing Apache HTTP is always fun. A few days back, I was installing Apache 2.4 on CentOS VM and encountered multiple errors.

    I thought it would be helpful to put together for a reference.

    APR not found

    [[email protected] httpd-2.4.25]# ./configure --enable-ssl
    checking for chosen layout... Apache
    checking for working mkdir -p... yes
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking build system type... x86_64-unknown-linux-gnu
    checking host system type... x86_64-unknown-linux-gnu
    checking target system type... x86_64-unknown-linux-gnu
    configure: 
    configure: Configuring Apache Portable Runtime library...
    configure: 
    checking for APR... no
    configure: error: APR not found.  Please read the documentation.
    [[email protected] httpd-2.4.25]#

    APR stands for “Apache Portable Runtime” and needed to compile from the source. If you are in the same situation as me then following will rescue you.

    First, you need to install APR.

    • Download the latest version of APR using wget
    wget https://www-eu.apache.org/dist/apr/apr-1.6.3.tar.gz .
    • Extract the downloaded file
    gunzip -c apr-1.6.3.tar.gz | tar xvf -
    • it will create a new folder “apr-1.6.3
    • Go inside and compile with configure command
    ./configure

    It will take a few seconds and once done you will get a prompt back (ensure no error).

    • The last step would be to install using make command
    make
    make install

    Once done, I tried installing Apache and got another error.

    APR-util not found

    [[email protected] httpd-2.4.25]# ./configure --enable-ssl --enable-so
    checking for chosen layout... Apache
    checking for working mkdir -p... yes
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking build system type... x86_64-unknown-linux-gnu
    checking host system type... x86_64-unknown-linux-gnu
    checking target system type... x86_64-unknown-linux-gnu
    configure: 
    configure: Configuring Apache Portable Runtime library...
    configure: 
    checking for APR... yes
      setting CC to "gcc"
      setting CPP to "gcc -E"
      setting CFLAGS to " -g -O2 -pthread"
      setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
      setting LDFLAGS to " "
    configure: 
    configure: Configuring Apache Portable Runtime Utility library...
    configure: 
    checking for APR-util... no
    configure: error: APR-util not found.  Please read the documentation.
    [[email protected] httpd-2.4.25]#

    In case you have “APR-util not found” error as well then you got to install the following.

    • Download the latest APR-util source
    wget https://www-eu.apache.org/dist/apr/apr-util-1.6.1.tar.gz .
    • Extract the downloaded gz file
    gunzip -c apr-util-1.6.1.tar.gz | tar xvf -
    • Go inside the newly created folder “apr-util-1.6.1” and install using the following commands
    ./configure --with-apr=/usr/local/apr/bin/apr-1-config
    make
    make install

    Tried installing Apache again and got another error.

    pcre-config for libpcre not found

    This is what I got.

    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking how to run the C preprocessor... gcc -E
    checking for gcc option to accept ISO C99... -std=gnu99
    checking for pcre-config... false
    configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

    PCRE stands for Perl Compatible Regular Expressions, and this error got an easy solution. You just to install pcre-devel package.

    yum install pcre-devel

    Not over yet, got another in next attempt related to OpenSSL.

    OpenSSL version is too old

    checking whether to enable mod_slotmem_plain... no
    checking whether to enable mod_ssl... checking dependencies
    checking for OpenSSL... checking for user-provided OpenSSL base directory... ./configure: line 25426: cd: /usr/bin/openssl: Not a directory
    /root/httpd-2.4.25
      adding "-I/root/httpd-2.4.25/include" to CPPFLAGS
      setting MOD_CFLAGS to "-I/root/httpd-2.4.25/include"
      setting ab_CFLAGS to "-I/root/httpd-2.4.25/include"
      adding "-L/root/httpd-2.4.25/lib" to LDFLAGS
      setting MOD_LDFLAGS to "-L/root/httpd-2.4.25/lib"
    checking for OpenSSL version >= 0.9.8a... FAILED
    configure: WARNING: OpenSSL version is too old
    no
    checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
    [[email protected] httpd-2.4.25]#

    The first thing you have to ensure you have the latest version of OpenSSL which was in my case, so I needed to install the devel package, and it was all right.

    yum install openssl-devel

    xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory

    While compiling APR, I got this error.

    [[email protected] apr-util-1.6.1]# make
    make[1]: Entering directory `/opt/temp/apr-util-1.6.1'
    /bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/opt/temp/apr-util-1.6.1/include -I/opt/temp/apr-util-1.6.1/include/private  -I/usr/local/apr/include/apr-1    -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>
                       ^
    compilation terminated.
    make[1]: *** [xml/apr_xml.lo] Error 1

    If you are getting this error, then this can be resolved by installing expat-devel package.

    yum install expat-devel

    configure: error: no acceptable C compiler found in $PATH

    C compiler not found is typical for any software build, and you can fix this by installing the compiler.

    yum install gcc

    nghttp2 version is too old

    This is specific to when you try to install Apache with HTTP/2. You will get the following error.

    checking whether to enable mod_http2... checking dependencies
    checking for OpenSSL... (cached) yes
      setting MOD_LDFLAGS to "  -lssl -lcrypto -lrt -lcrypt -lpthread"
      setting MOD_CFLAGS to " "
      setting MOD_CPPFLAGS to "-DH2_OPENSSL"
    checking for nghttp2... checking for user-provided nghttp2 base directory... none
    checking for pkg-config along ... checking for nghttp2 version >= 1.2.1... FAILED
    configure: WARNING: nghttp2 version is too old
    no
    checking whether to enable mod_http2... configure: error: mod_http2 has been requested but can not be built due to prerequisite failures

    And, if so, you can fix by installing nghttp2 as below.

    • Download the latest version of nghttp2 from here
    wget https://github.com/nghttp2/nghttp2/releases/download/v1.37.0/nghttp2-1.37.0.tar.gz
    • Extract the downloaded file
    tar -xvf nghttp2-1.37.0.tar.gz
    • It will create a new folder, go inside that and run the following
    ./configure
    make
    make install

    Once done without error, run the Apache source build with HTTP2 again. It should be alright.

    Finally, I was able to install Apache successfully. If you are interested in learning about Apache HTTP Server Administration, then check out this online course.