Apache web server is one of the most used web servers in the world. It is very easy to configure. It is open-source software and maintained by the Apache Software Foundation. Apache supports numerous features. Many of these features are implemented as compiled modules to expand the core functionality.

httpd is an apache web server in Red Hat-based distros, while it is called apache on Debian distros. It depends on the OS you use. For example, in RHEL 6.2, it is called httpd, and in Ubuntu, it is called apache2.

In Fedora Linux, the httpd package provides the Apache webserver application.

What will we cover

In this tutorial, we will see how to install Apache webserver from the source file as well as from the Fedora repository.

It is recommended that you first read this post and then apply it to your system. This will make sure that you correctly configure the apache web server.

Prerequisites

  1. Fedora Operating System installed
  2. User account with root access
  3. Internet connectivity to download various files.

Method 1. Installing from source code

Step 1. Open a web browser and go to the apache download page. At this article’s writing, the latest and stable version available for Apache HTTP Server (httpd) is 2.4.46. Download the file as shown below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/1-7.jpg" data-lazy- height="388" src="data:image/svg xml,” width=”1161″>

Another way to get the file is using the wget command. Open the terminal and run the following command:

# wget https://mirrors.estointernet.in/apache//httpd/httpd-2.4.46.tar.gz

This is shown below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/2-6.jpg60293900664e7.jpg" data-lazy- height="497" src="data:image/svg xml,” width=”1295″>

The benefit of using the source code is that you always get the latest available version of the software.

Step 2. Once we get the source file, we can start with the commands’ gzip’ and ‘tar’ to extract the file. The exact name of the file depends on the available version you have downloaded. In our case, it is httpd-2.4.46.tar.gz.

# gzip -d httpd-2.4.46.tar.gz

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/3-6.jpg60293900cfa15.jpg" data-lazy- height="94" src="data:image/svg xml,” width=”1291″>

# tar xvf httpd-2.4.46.tar

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/4-7.jpg" data-lazy- height="108" src="data:image/svg xml,” width=”1292″>

After running the above command, you can see the extracted folder as here:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/5-6.jpg" data-lazy- height="725" src="data:image/svg xml,” width=”1340″>

Step 3. Now go to the extracted directory with the command:

Step 4. We now need to run the configure script to configure the apache. This is available inside the root directory of apache, i.e., the current directory. But before running this script, make sure where you want to install apache.

You can install the apache server in the default location. For this, you have to run the script simply:

If you want to install apache in a directory other than the default, use the following syntax:

# ./configure –prefix=/path/of/installation

Inside the ‘–prefix=’ enter the path of installation. In our case, we will install apache inside the /opt/httpd directory. For this, follow the instruction below:

1. Create a directory inside /opt as shown below:

2. Run the script as shown below:

# ./configure –prefix=/opt/httpd

The configure script will take some time to run and verify the features on your system. It will also prepare Makefiles to compile the apache web server.

Note for several errors when running the ./configure script:

1. You may get the following error “configure: error: APR not found”:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/6-5.jpg" data-lazy- height="514" src="data:image/svg xml,” width=”1299″>

For fixing this error, you need to download the apr-*.tar.gz from here.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/7-4.jpg" data-lazy- height="606" src="data:image/svg xml,” width=”1190″>

Now extract this directory inside the ‘srclib’ directory, which is available in the apache httpd distribution folder. To extract the file, use the command:

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

# tar xvf apr-1.7.0.tar.gz

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/8-2.jpg" data-lazy- height="489" src="data:image/svg xml,” width=”1297″>

Now rename these files by removing the version number as here:

# mv apr-util-1.6.1 apr-util

# mv apr-1.7.0 apr

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/9-2.jpg" data-lazy- height="325" src="data:image/svg xml,” width=”1295″>

2. If the error is “configure: error: pcre-config for libpcre not found.” Then you just need to install the PCRE devel package as shown below:

# dnf install pcre-devel -y

Now continue to run the configure script as before. In last it would print the summary as shown here:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/10-2.jpg" data-lazy- height="398" src="data:image/svg xml,” width=”1268″>

Step 5. To build the several components that comprise the Apache web server, use the following command:

This may take significant time to run this command as it will compile the base configuration. It largely depends on system hardware and also on the number of modules enabled.

If you get an error like “fatal error: expat.h: No such file or directory”, you will need to download expat from here. Now extract the file inside some directory. We are using /opt/httpd for extraction.

# tar xvjf expat-2.2.10.tar.bz2 -C /opt/httpd

Now go to the extracted directory and run the following command one by one to configure expat:

# cd /opt/httpd/expat-2.2.10

# ./configure

# make

# make install

Now again run the configure script by specifying the path of expat installation:

# ./configure –prefix=/opt/httpd  –with-expat=/opt/httpd/expat-2.2.1

Step 5. Once the make command finishes, we are ready to install the packages. Run the command:

Step 6. To customize your apache server, use the httpd.conf file located inside:

# nano PREFIX/conf/httpd.conf

Where PREFIX is the path of apache installation. In our case it is /opt/httpd/, so we use:

# nano /opt/httpd/conf/httpd.conf

Inside this file, change the ServerName directive to the IP address of your system.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/11-2.jpg" data-lazy- height="721" src="data:image/svg xml,” width=”1289″>

Step 7. Now apache is ready to use; we only need to start the service from the directory where it is installed. For e.g., if you have installed the apache inside /opt/httpd, then run the command:

# /opt/httpd/bin/apachectl -k start

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/12-1.jpg" data-lazy- height="319" src="data:image/svg xml,” width=”1506″>

Method 2. Installing from Fedora Repository

Installing Apache httpd from the Fedora repository is quite easy; just follow the below steps:

Step 1. Open a terminal (ctrl alt f2) with root user or at least with superuser privileges.

Step 2. Now use the following command to install apache:

Step 3. Start and check the status of the apache service with the command:

# systemctl start httpd.service

# systemctl status httpd.service

It should show a running status

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/13-1.jpg" data-lazy- height="518" src="data:image/svg xml,” width=”791″>

Step 4. Open a web browser and enter your system IP. It would show the following page:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/14-1.jpg602939067d953.jpg" data-lazy- height="579" src="data:image/svg xml,” width=”797″>

Conclusion

Congratulations, You have successfully configured the Apache webserver. In this guide, we have learned how to install apache from the source file and Fedora repository.

About the author

<img alt="Ali Imran Nagori" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/IMG_20201123_090644_2-150×150.jpg6029390683ab9.jpg" height="112" src="data:image/svg xml,” width=”112″>

Ali Imran Nagori

Ali imran is a technical writer and Linux enthusiast who loves to write about Linux system administration and related technologies. You can connect with him on LinkedIn


.