Fedora

How to Install and configure Apache httpd on Fedora Linux

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:

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:

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

# tar xvf httpd-2.4.46.tar

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

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

# cd httpd-2.4.46

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:

# ./configure

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:

# mkdir /opt/httpd

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”:

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

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

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

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:

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

# make

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:

# make install

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.

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

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:

# dnf install httpd

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

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

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

Ali Imran Nagori

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
.