Challenge 1: Two VirtualHost Blocks for Two Different Sites — Solution Walkthrough
The configuration:
ServerName site-a.example
DocumentRoot /var/www/site-a
ServerName site-b.example
DocumentRoot /var/www/site-b
Why this works:
Both blocks listen on the same IP and port (*:80), which is exactly
the situation this chapter describes — one server, one IP, multiple
sites. Apache distinguishes between the two purely by matching each
incoming request's Host header against each block's own ServerName:
a request with Host: site-a.example is routed to the first block's
DocumentRoot, and a request with Host: site-b.example is routed to
the second block's DocumentRoot, even though both blocks are listening
on the identical *:80.
WHY THIS WORKS AS AN ANSWER
------------------------------
This exercise is a direct, hands-on application of this chapter's own
Apache VirtualHost syntax to a concrete two-site scenario — correctly
using the same *:80 listen address for both blocks, differentiated
only by ServerName, demonstrates the actual mechanism (Host-header
matching) rather than assuming each site needs its own IP or port.