audioduck Posted January 3, 2008 Share Posted January 3, 2008 Hi Guys, Sorry if this sounds a bit lame but I'm a newb. I'm running Apache on a Red Hat machine. The machine has the domain name of foo.com and I have a web site called www.foo.com. I want to run 3 sites (foo.com, bar.com, baz.com) under Apache. Do I configure a VirtualHost with the domain name of foo.com so that all of the serviced domains (foo.com, bar.com, baz.com) are equal or do I leave foo.com as a "primary" domain with the same name as the machine and just configure bar.com and baz.com as VirtualHosts? Why don't I understand?! Cheers, Matt Quote Link to comment https://forums.phpfreaks.com/topic/84364-solved-virtualhost-with-same-domain-name-as-machine/ Share on other sites More sharing options...
audioduck Posted January 3, 2008 Author Share Posted January 3, 2008 Panic over. Sorry about this. It was clear as day in the documentation: **************************************** Main host goes away If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host. For example, suppose that you are serving the domain www.domain.tld and you wish to add the virtual host www.otherdomain.tld, which points at the same IP address. Then you simply add the following to httpd.conf: NameVirtualHost *:80 <VirtualHost *:80> ServerName www.domain.tld ServerAlias domain.tld *.domain.tld DocumentRoot /www/domain </VirtualHost> <VirtualHost *:80> ServerName www.otherdomain.tld DocumentRoot /www/otherdomain </VirtualHost> **************************************** Quote Link to comment https://forums.phpfreaks.com/topic/84364-solved-virtualhost-with-same-domain-name-as-machine/#findComment-429762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.