The evolution of an Apache virtual host


The simplest virtual hosts

When an HTTP request comes into the IP address and Port 80, the Apache server will detect the hostname in the request and route the request to the directory declared in the DocumentRoot.

Adding www

It is still not uncommon for people to search for domains by adding www, for example and

To make them both route to the same place we simply add a ServerAlias declaration in our virtualhost. Now when someone visits or they will be served the same files.

This is of course assuming you have set up your DNS to point www to your IP address.

Serving files from a user’s home directory.

Writing Apache error and access logs to a user’s home directory.

Leave a Reply

Your email address will not be published. Required fields are marked *