Monday, June 25, 2018

Compile Apache latest version 2.4.33 on Centos 7 from source code

Installing Apache on windows is an easy task like it has come with the .exe package and you just need to install it as per the instructions. But in other hands when you are going to compile it on Linux system that time you first need to understand the requirements of system and Apache web server before start installing it on Linux.
Before starting to compile Apache, we need to install some default dependencies which is required to compile apache.
The first dependency is gcc and gcc-c++, run the below yum install command to install this dependecy.
$ yum install gcc gcc-c++
Install wget package [if not present on your system] which is used to download the latest Apache and other packages on the server.
$ yum install wget
Now, download the below packages with the help of wget command in /opt/ directory [you can choose any directory as per your requirement].
cd /opt/
wget https://archive.apache.org/dist/httpd/httpd-2.4.33.tar.gz
wget https://www.openssl.org/source/openssl-1.0.2o.tar.gz
wget https://www.redrockdigimark.com/apachemirror/apr/apr-1.6.3.tar.gz
wget https://www.redrockdigimark.com/apachemirror/apr/apr-util-1.6.1.tar.gz
wget http://ftp.cs.stanford.edu/pub/exim/pcre/pcre-8.41.tar.gz
Now extract downloaded packages one by one and install it as per the instructions are given below, 

DEPENDENCY PACKAGES :

$ tar -xvf apr-1.6.3.tar.gz

cd apr-1.6.3
./configure --prefix=/data/Apache/apr
make
make install

$ tar -xvf apr-util-1.6.1.tar.gz

cd apr-util-1.6.1/
./configure --prefix=/data/Apache/apr-util --with-apr=/data/Apache/apr
make
make install

$ tar -zxvf openssl-1.0.2o.tar.gz

cd openssl-1.0.2o/
echo "Current directory `pwd`"
./Configure
./conig -fPIC --prefix=/data/Apache/ssl
make
make install

$ tar -xvf pcre-8.41.tar.gz

cd pcre-8.41
./configure –prefix=/data/Apache/pcre 
make
make install

COMPILE APACHE :

Now we are going to compile apache with all the above installed packages,
$ tar -xvf httpd-2.4.33.tar.gz

cd httpd-2.4.33
./configure --prefix=/data/Apache --with-apr=/data/Apache/apr --with-apr-util=/data/Apache/apr-util --with-ssl=/data/Apache/ssl --enable-mods-shared=all --enable-deflate --enable-ssl --enable-so
make
make install

CHECK OPESSL VERSION :

cd /DATA/Apache2433/modules
strings mod_ssl.so | egrep ‘^mod_ssl\/|^OpenSSL ‘
Start the Apache service using below command,
cd /usr/local/Apache2433/bin
./httpd -k start

CHECK COMPILE APACHE VERSION

./httpd -v
Server version: Apache/2.4.33 (Unix)
Server built: Jun 14 2018 12:15:36

BROWSE URL

Browse : http://local-server-ip/
compile apache