# VirtualHost for www.wiley-bible.com <VirtualHost *>
ServerName www.wiley-bible.com DocumentRoot /srv/www/vhosts/wiley-bible ErrorLog /var/log/apache2/wiley-bible-error_log CustomLog /var/log/apache2/wiley-bible-access_log combined <Directory "/srv/www/vhosts/wiley-bible"> Order allow.deny Allow from all </Directory> </VirtualHost>
This virtual host operates on the same IP address as the default server. It depends on the fact that DNS gives the same IP address for the host www.wiley-bible.com as it does for the name associated with the default server (the real host name of the server machine). When an HTTP request comes in for http://www.wiley-bi'ble.com/i'ndex.html, the fact that the HTTP request header specifies the host www.wiley-bible.com tells the Apache server that the page it needs to serve is /srv/www/vhosts/wiley-bible/index.html rather than the default /srv/www/htdocs/index.html.
If you have multiple virtual hosts you should add a line to the file /etc/apache2/listen .conf:
Then each virtual host declaration should start with:
You can be more specific and replace the * by the IP address and port number but this is not necessary for a simple, name-based virtual hosts configuration.
i- : i , There is good information about setting up virtual hosts in the official Apache r1^** documentation at http://httpd.apache.org/docs/2.2/vhosts
/name-based.html. A common problem reported is that the default server ''goes away'' when a virtual host is first defined. Once you have defined a name-based virtual host, you must add the default server as a virtual host also. Otherwise, you will see the first virtual host when you access the server by its default name.
f You can test your virtual host configuration with the command apache2ctl -S. This will report on the virtual hosts that are visible when the configuration you have written becomes active.
Was this article helpful?