Resolving ‘APR not found’ Errors and Installing Apache from Source on CentOS
This guide explains how to clean existing packages, disable SELinux, install required build tools, download and compile APR, APR‑util and PCRE, and finally compile and install Apache HTTP Server on a CentOS system using a Bash script.
This article addresses the common configure: error: APR not found problem when building Apache from source and provides a step‑by‑step solution.
1. Remove existing packages
rpm -e httpd rpm -e mysql rpm -e php yum -y remove httpd yum -y remove mysql yum -y remove php rpm -qa http* rpm -e --nodeps <package_name> rpm -qa | grep http*Check for leftover Apache files.
2. Disable SELinux (if it interferes with compilation)
Permanent (requires reboot):
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/configTemporary (no reboot needed):
setenforce 03. Install required development tools
yum -y install make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel gmp-devel pspell-devel unzip libcap lsofInstalling these ensures all dependencies are satisfied.
4. Download source packages
wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip
5. Compile and install APR
tar -zxf apr-1.4.5.tar.gz cd apr-1.4.5 ./configure --prefix=/usr/local/apr make && make install6. Compile and install APR‑util
tar -zxf apr-util-1.3.12.tar.gz cd apr-util-1.3.12 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config --enable-utf8 make && make install7. Compile and install PCRE
unzip -o pcre-8.10.zip cd pcre-8.10 ./configure --prefix=/usr/local/pcre make && make install8. Bash script to automate Apache installation
#!/bin/bash
# Install Apache
H_URL=http://mirrors.sohu.com/apache/
H_FILES=httpd-2.4.29.tar.bz2
H_PREFIX=/usr/local/apache
H_FILES_DIR=httpd-2.4.29
if [[ $1 -eq 1 ]]; then
wget -c $H_URL/$H_FILES && tar -jxvf $H_FILES && cd $H_FILES_DIR \
&& ./configure --prefix=$H_PREFIX \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-pcre=/usr/local/pcre
if [[ $? -eq 0 ]]; then
make && make install
echo -e "\033[32m---Apache install successful---\033[0m"
else
echo -e "\033[32m---Apache install failed---\033[0m"
exit 0
fi
fiAfter the script finishes, start Apache with:
/usr/local/apache/bin/apachectl startImages in the original article illustrate the script output and final verification.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.