This guide will help you modify, compile and install a custom HTTPD server!
To download the HTTPD Source code, you can go to the Apache Site. Or you could just directly download the file into your downloads folder like so
(On the day of creating this guide, the latest version is 2.4.41)
wget https://www-us.apache.org/dist//httpd/httpd-2.4.41.tar.gz
Extract the gzip like so
gzip -d httpd-2.4.41.tar.gz
tar xvf httpd-2.4.41.tar
Now, you should see a directory containing all the files required to build httpd
To add a custom version name, you can navigate to include/ap_release.h
where it contains the httpd versioning parameters and modify the AP_SERVER_ADD_STRING
.
#if !AP_SERVER_DEVBUILD_BOOLEAN
#define AP_SERVER_ADD_STRING "-gci"
#else
#ifndef AP_SERVER_ADD_STRING
#define AP_SERVER_ADD_STRING "-gci-dev"
#endif
#endif
To configure the build, you can easily run the provided configure
file
./configure
This will automatically configure to install to /usr/local/apache2
. If you wanted to install this somewhere else you can define the prefix parameter and the path where you want it to be installed.
./configure --prefix=/path/to/installation
To compile and install the custom Apache HTTPD server, run
make
and then
sudo make install
This will compile and install automatically to /usr/local/apache2
.
To start the server, you can run
sudo /usr/local/apache2/bin/apachectl -k start
or
sudo /path/to/installation/bin/apachectl -k start
After starting the server, you can test it by going to localhost
and it should return you the index.html
The logs will also include your custom name, to check it you can go to logs/error_log
in your installation.
[Fri Jan 10 20:17:50.912250 2020] [mpm_event:notice] [pid 16855:tid 140452566600640] AH00489: Apache/2.4.$
[Fri Jan 10 20:17:50.912731 2020] [core:notice] [pid 16855:tid 140452566600640] AH00094: Command line: '/$
You can replace the index.html
that is located in the htdocs
of your installation to see if it works!
Congratulations! You've build your own custom apache server!