The term Virtual Host refers to the practice of running more than one web site on a single machine. Virtual hosts can be "IP-based", meaning that you have a different IP address for every web site, or "Name-based", meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.
To use name-based Virtual Host come through the next steps:
- Click Config button for Apache server in your environment.
- Navigate to conf > httpd.conf.
- Before you actually start configuring your virtual host make sure you have the NameVirtualHosts line uncommented:
- Then find < VirtualHost > block.
- You should create < VirtualHost > block for each different host that you would like to serve. Note, that the argument to the < VirtualHost > directive must match a defined NameVirtualHost directive (in our case it is *:80). Inside each < VirtualHost > block, you will need at minimum 2 directives:
- ServerName directive to uniquely identify a virtual host. Preferably enter here the main hostname of your site.
- DocumentRoot directive to show where in the filesystem the content for that host lives.
To find out if a particular directive is allowed follow the link. Configuration directives set in the main server context (outside any < VirtualHost > container) will be used only if they are not overridden by the virtual host settings.