You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Anilkumar DK <An...@trianz.com> on 2008/06/17 12:49:48 UTC
[users@httpd] Query on Name-Based Virtual host (Default Virtual Host Block)
Hi,
Is it mandatory that the first virtual host block should contain default
host DocumentRoot so that resources can be accessed through virtual host
server?
If I configure httpd.conf for Apache Webserver 2.0.59 (on Solaris) as
below
with
enterprise3.xyz.com pointing to Document Root as /usr/ga/Apa/htdocs
(default host)
vs1.xyz.com pointing to Document Root as /usr/ga/Apa/htdocs1 (virtual
server)
vs2.xyz.com pointing to Document Root as /usr/ga/Apa/htdocs2 (virtual
server)
I can access corresponding resources in each of these servers.
But if I remove the first Virtual Host block (i.e., used as default
host) then I can't access any of the resources in these 3 servers.
If I remove the first Virtual Host block and if the second VirtualHost
block is modified to DocumentRoot as /usr/ga/Apa/htdocs (keeping
everything else same as earlier setup), I can access the resources in
/usr/ga/Apa/htdocs through vs1.xyz.com (and can't access the resources
from other 2 servers).
Is it mandatory that the first virtual host block should contain default
host DocumentRoot (if the first virtual host block is not the default
host) so that resources can be accessed through virtual host server?
# Use name-based virtual hosting.
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /usr/ga/Apa/htdocs
ServerName enterprise3.xyz.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /usr/ga/Apa/htdocs1
ServerName vs1.xyz.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /usr/ga/Apa/htdocs2
ServerName vs2.xyz.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
Regards,
Anil