In this post we will learn about how to manually install Apache HTTP Server (httpd) from the source tarball file and set up a custom site project, follow this step-by-step guide:

Step 1: Install Prerequisites

Before proceeding with the installation, ensure that your system has the necessary prerequisites. Open a terminal and run the following commands to install them:

For RPM-based distributions (Fedora, CentOS, etc.):

sudo dnf install gcc pcre-devel openssl-devel apr-devel apr-util-devel

For Debian-based distributions (Ubuntu, Debian, etc.):

sudo apt-get update
sudo apt-get install build-essential libpcre3-dev libssl-dev libapr1-dev libaprutil1-dev

Step 2: Download the Apache HTTP Server Source

Visit the official Apache HTTP Server website and download the latest stable source tarball. Alternatively, use the following command to download it directly from the terminal:

wget https://downloads.apache.org/httpd/httpd-{version}.tar.gz

Replace {version} with the specific version number you wish to install.

Step 3: Extract the Source Tarball

Navigate to the directory where the downloaded tarball is located and extract its contents using the following command:

tar -xf httpd-{version}.tar.gz

Step 4: Configure, Compile, and Install Apache

Change to the extracted source directory:

cd httpd-{version}

Run the following commands in sequence to configure, compile, and install Apache:

./configure --prefix=/usr/local/apache
make
sudo make install

The --prefix option specifies the installation directory. You can modify it according to your preference.

Step 5: Start Apache

Start Apache using the following command:

sudo /usr/local/apache/bin/apachectl start

Apache should now be up and running on your system.

Step 6: Add a Custom Site Project

To create a custom site project and serve it with Apache, follow these steps:

  1. Create a new directory for your project under the Apache document root:
sudo mkdir /usr/local/apache/htdocs/myproject
  1. Place your project files inside the newly created directory:
sudo cp -R /path/to/project/files/* /usr/local/apache/htdocs/myproject

Replace /path/to/project/files with the actual path to your project files.

  1. Create a new configuration file for your site project:
sudo nano /usr/local/apache/conf/extra/myproject.conf

Add the following content to the file:

<VirtualHost *:80>
    ServerName myproject.local
    DocumentRoot /usr/local/apache/htdocs/myproject
    ErrorLog logs/myproject-error_log
    CustomLog logs/myproject-access_log common
</VirtualHost>

Replace myproject.local with the desired domain name for your project.

  1. Save the file and exit the text editor.
  2. Open the main Apache configuration file:
sudo nano /usr/local/apache/conf/httpd.conf
  1. Add the following line at the end of the file to include your custom site configuration:
Include conf/extra/myproject.conf
  1. Save the file and exit the text editor.
  2. Restart Apache for the changes to take effect:
sudo /usr/local/apache/bin/apachectl restart

Step 7: Access Your Custom Site Project

Open a web browser and enter http://myproject.local (replace with your chosen domain name) in the address bar. You should see your custom site project being served by Apache.

That’s it! You have successfully installed Apache HTTP Server from source and set up a custom site project. You can now further customize Apache’s configuration and explore advanced features as per your project requirements.