Named-based virtual hosting

First you need to declare the IP used for virtual hosting with the NameVirtualHost directive:

NameVirtualHost 192.168.0.1

# ip above is just an example

# the above directive specifies that requests for this IP must be further devised

Second you need to form the VirtualHost container

<VirtualHost 192.168.0.1>

</VirtualHost>

Main sub directives

ServerName

This sets the site’s name which more importantly set the value for the HOST header specific to name-based virtual hosting.

DocumentRoot

This sets the location of the Webspace user files served to the client for the specific HOST.

ErrorLog

This specifies the path of the error log.

TransferLog

This specifies the path of the transfer log.

Example

NameVirtualHost 192.168.0.1

<VirtualHost 192.168.0.1>

ServerName site1.com

ServerAdmin [email protected]

DocumentRoot /home/site1

ErrorLog /path

TransferLog /path

</VirtualHost>

<VirtualHost 192.168.0.1>

ServerName site1.com

ServerAdmin [email protected]

DocumentRoot /home/site1

ErrorLog /path

TransferLog /path

</VirtualHost>

Uncategorized