You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Adam Roberts <ad...@lonetree.com> on 2005/11/02 06:57:08 UTC

[users@httpd] VirtualHost confusion

It has been a longtime since I have needed to use <VirtualHost>'s and now my
ignorance has caught up with me.

I have a two domain names (domain1.com and domain2.net) that I am trying to
host on the same machine with VirtualHost, however, I'm not having much
luck.

Background:
Apache2 running on RHEL 3 ES Update 6.

VirtualHost snippet from /etc/httpd/conf/httpd.conf
----------------------------------------------------------

NameVirtualHost <ip-address>:80

<VirtualHost <ip-address>>
        ServerName www.domain2.net
        ServerAdmin webmaster@domain2.net
        DocumentRoot /var/www/html/domain2
        ServerAlias www.domain2.net domain2.net
</VirtualHost>

<VirtualHost <ip-address>>
        ServerName www.domain1.com
        ServerAdmin webmaster@domain1.com
        DocumentRoot /var/www/html
        ServerAlias www.domain1.com domain1.com
</VirtualHost>

----------------------------------------------------------

Of the different variations of this section I have read in books and other
posts, this appears to be the most common setup.

Here's my problem:

When I try to access either domain from my web browser (Firefox 1.0.7), I
can only see the pages for domain1.com.  If I go to domain2.net, I am served
the pages for domain1.com.  Thus far, I am stumped.  I managed to create
configuration files that served no pages, errors, one but not the other, but
never successfully both.  This current configuration is the best I have come
up with so far.

I own both of these domains and the DNS for these domains are pointing to
the correct IP address, as indicated by getting something when I enter
either address.

Any help would be very much appreciated.  

Thanks!!
Adam R.  



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] VirtualHost confusion

Posted by Sean Brown <se...@gmail.com>.
On 11/2/05, Adam Roberts <ad...@lonetree.com> wrote:
> It has been a longtime since I have needed to use <VirtualHost>'s and now my
> ignorance has caught up with me.
>
> I have a two domain names (domain1.com and domain2.net) that I am trying to
> host on the same machine with VirtualHost, however, I'm not having much
> luck.
>
> Background:
> Apache2 running on RHEL 3 ES Update 6.
>
> VirtualHost snippet from /etc/httpd/conf/httpd.conf
> ----------------------------------------------------------
>
> NameVirtualHost <ip-address>:80
>
> <VirtualHost <ip-address>>
>         ServerName www.domain2.net
>         ServerAdmin webmaster@domain2.net
>         DocumentRoot /var/www/html/domain2
>         ServerAlias www.domain2.net domain2.net
> </VirtualHost>

If you do NameVirtualHost <ip-address>:80, you need to do <VirtualHost
<ip-address>:80>.  Also, though probably not the problem, there's no
need to put ServerAlias  www.domain2.net when you've already named it
as the ServerName.

Finally, make sure to restart Apache after you've made those changes
before you try again.

Sean

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org