Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a server with IP address 192.168.1.65

I want to setup virtual hosting such that:

(xyz.com is already pointing to 192.168.1.65 in dns server)

share|improve this question

1 Answer 1

The "default host" should be your doc-root A. Then add name based virtual hosts for B and any additional domains.

In your main config file default configurations including DocumentRoot should be setup for hosting site A. Also you should have a line such as NameVirtualHost *:80 to setup virtual hosting for everything on port 80. Then in your virtual host file you will have something like this for each domain:

<VirtualHost *:80>
    ServerName xyz.com
    DocumentRoot /path/to/B
</VirtualHost>

Anything without a virtual host and matching server name will use the default host, with your docroot set to A.

share|improve this answer
    
i have added a name based virtual host. the problem now seem that since the IP and the domain are pointing to the same machine using same port, when i type the domain, the browser lead me to DocRoot A which is the same as the ip address –  Yang Zheng Apr 13 '11 at 11:06
1  
Yang it is possible to host different sites for the IP address when called directly and various domains that point to the same IP address. Your problem is your configs ... if you have the default setup correctly to catch unknown names, this will catch the IP address-as-name senario as well. It sounds like your virtualhost is not being recognized at all. –  Caleb Apr 13 '11 at 11:15
    
what are the setting i need to mod? i mean the 'default setup' catching unknown names. –  Yang Zheng Apr 13 '11 at 11:30
    
i do have the NameVirtualHost *.80 specified in ports.conf file. and the virtual host file is very similar to yours (only diff are mine have ServerAlias option specified). I use the -S option to check the syntax of the vhost file, it says OK. –  Yang Zheng Apr 13 '11 at 11:33
    
The most relevant settings are in my answer already, including haveing a DocumentRoot directive in the common config file outside of any VirtualHost container. If you are still having trouble it might be helpful to post your current configs to pastebin.com or some such place so we can look at them. –  Caleb Apr 13 '11 at 11:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.