Configuring Apache 2.4 consists of the following steps (CentOS/RedHat/Amazon Linux 2):

1) You install the server using:

yum install -y httpd

Start the service:

systemctl start httpd

Enable it on every boot-up:

systemctl enable httpd
A configuration directory is located here:


And to configure your web-application to be served, use /etc/httpd/conf.d

Apache uses a concept of Virtual Hosts. Each virtual host can serve a logically separated hostname, that will appear as a separate web site. Every Virtual Host is serving on a single specific port, but the ports can be reused. Therefore normally you will have each VirtualHost for the two most used ports - 80 and 443 duplicated.

Nowadays, port 80 will most likely perform the only action - redirect to VirtualHost on port 443. To distinguish VirtualHosts, a hostname is used. A hostname that arrives at the server using Host header should match the ServerName or ServerAlias in your specific VirtualHost. Else, a default virtual host will be used. A default is the topmost VirtualHost in your configuration, or a VirtualHost, that is in the file in conf.d directory, which is the topmost as per alphabet.

<VirtualHost *:80>    
    DocumentRoot "/www/example1"    
    # Other directives here
<VirtualHost *:80>   
    DocumentRoot "/www/example2"    
    # Other directives here

The most common mistake people make is omitting the Directory directive inside of the VirtualHost. It is very important, because it is a security mechanism of Apache, allowing to determine rules of accessing a certain location and files within it.

Therefore you should include similar code in every VirtualHost (adjust the directory path respectively):

<Directory "/www/example1">  
Require all granted 

Once you are done, the content from /www/example1 will become visible over your web-browser.