Skip to main content

LFCS Certification Course

Chapter #23: The Apache Web Server

Learn how to configure Apache Web Server, set up virtual hosts, and SSL (self-signed & Letโ€™s Encrypt) for the LFCS certification.

In this chapter, we will show you how to configure Apache to serve web content, set up name-based virtual hosts, and implement SSL, including a self-signed certificate.

๐Ÿ’ก
Note that this chapter is not a comprehensive guide on Apache but rather a starting point for self-study for the LFCS exam.

For the same reason, we are not covering load balancing here either.

You may already know other ways to perform the same tasks, which is OK, considering that the Linux Foundation Certification exams are strictly performance-based. Thus, if you โ€˜get the job doneโ€™, you stand good chances of passing the exam.

By now, you should have the Apache web server installed and running. If it is not yet installed, you can install it with the following commands:

For RHEL:

sudo yum update
sudo yum install httpd -y
sudo systemctl enable --now httpd.service

For Ubuntu:

sudo apt update
sudo apt install apache2 -y
sudo systemctl enable --now apache2

Once installed, you can verify that Apache is running with the following command:

ps -ef | grep -Ei '(apache|httpd)' | grep -v grep

Note that the above command checks for the presence of either apache or httpd (the most common names for the web daemon) among the list of running processes.

If Apache is running, you will get output like the following:

Find Running Apache/HTTPD Processes

The ultimate method of testing the Apache installation and checking whether itโ€™s running is launching a web browser and pointing to the IP address of the server.

We should be presented with the following screen, or at least a message confirming that Apache is working:

Check Apache Web Server

Otherwise, please refer to Chapter 18 for instructions on installing and starting Apache.

Configuring Apache Web Server

The main configuration file for Apache can be in different directories depending on your distribution:

/etc/apache2/apache2.conf  # Ubuntu
/etc/httpd/conf/httpd.conf # RHEL

Fortunately for us, the configuration directives are extremely well documented on the Apache project website. We will refer to some of them throughout this chapter.

Serving Pages in a Standalone Web Server

The most basic usage of Apache is to serve web pages in a standalone server where no virtual hosts have been configured. The DocumentRoot directive specifies the directory out of which Apache will serve web pages and other documents.