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
It will take 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: 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: *** [xml/apr_xml.lo] Error 1
If you are getting this error, then this can be resolved by installing
yum install expat-devel
Finally, I was able to install Apache successfully on Digital Ocean VPS.
Next, you may be interested in learning Apache HTTP server administration.