Build Apache from Source

Added: 2022-04-06 21:31:16 | Last: 2022-04-20 20:53:02

Here we compile apache with ssl module on RHEL 8.
1. Install gcc if it's not there
# dnf install gcc
# dnf groupinstall "Development Tools"
2. Download and build pcre, expat, apr, apr-util
# ./configure --prefix=/opt/apache/srclib/pcre; make; make install
3. Without openssl-devel, it would complain openssl is too old if we compile with ssl module
# yum install openssl-devel
4. Download httpd-2.4.53.tar.gz
5. Extract the source and compile with ssl module:
# export CFLAGS=”-m64″
# ./configure --prefix=/opt/apache --with-apr=/opt/apache/srclib/apr \
--with-apr-util=/opt/apache/srclib/apr-util \
--with-pcre=/opt/apache/srclib/pcre/bin/pcre2-config \
--enable-ssl --enable-so
6. Generate self-signed SSL cert
# mkdir /opt/apache/ssl; cd /opt/apache/ssl
# openssl genrsa -out domain.key 2048
# openssl req -key domain.key -new -x509 -days 365 -out domain.crt
7. Update /opt/apache/conf/httpd.conf and ssl.conf
8. Start apache
# /opt/apache/bin/apachectl -k start