Apache Virtual Host Problem
I know this is a very popular question that has been asked several times over in these forums but nothing so far that i have read has solved my problem. So ill post my own Vhosts question :)
my problem is this: i set up name based virtual hosts in apache 2 (running on Fedora Core 3) and all seemed to be working well. but when i came back to visit my site 30 mins later both domains default to the first site in the vhost list. this problem is very intermittent. about 50% of the time i get the proper web site for the domain i enter into the browser and 50% of the time i get the first site no mater what name i enter. here is a look at my vhost set up: NameVirtualHost *:80 <VirtualHost *:80> ServerName www.mydomain1.com ServerAlias mydomain1.com *.mydomain1.com DocumentRoot /var/www/mydomain1 <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory "/var/www/mydomain1"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> DirectoryIndex index.html </VirtualHost> <VirtualHost *:80> ServerName www.mydomain2.com ServerAlias mydomain2.com *.mydomain2.com DocumentRoot /var/www/mydomain2 <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory "/var/www/mydomain2"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> DirectoryIndex index.html </VirtualHost> I'm not sure what is causing this problem, i have changed my vhost configuration a million different ways to match that of others who solved their problems but i always end up with the same symptoms. any help would be great. |
And have you configured the DNS appropriately?
|
im assuming so since it does work at least half the time.
|
Quote:
As for internal DNS i was under the impression that you do not need to set up internal DNS for apache? |
Add an entry to /etc/hosts with your servers IP address and each of the sites as aliases.
192.168.1.100 www.host1.com www.host2.com www.host3.com The problem your having is Apache can't resolve the sites to an ip address, periodically, so it is defaulting to the first site in the list. This plagued me for a while until I figured out how to fix it. I have the same setup on my server at the house and use this solution. No problems what-so-ever. |
loose your a life saver.
i have been having this problem for weeks and i think this finaly solved my problem. the only think i am concerned about is if anything will auto update my hosts file in the future and mess with the current set up but for now all is well. :) thks again |
Oh for the love of GOD what is goin on here lol.
everything worked fine for about 2hrs after i made the changes you suggested and then to my horror it started acting up again. www.mydomain1.com and www.mydomain2.com are now both defaulting to mydomain1's index page. the url in the address bar shows the correct page but the page itself is coming up as the first page in the vhost list again. some times it works, some times it doesn't. Please help |
bump
|
Well, I would still suggest, use the DNS approach.
|
Quote:
Still not working I have set up the dns 192.168.0.100 www.thissite.com www.thatsite.com www.who.com but everything still going to www.thissite.com |
I didn't see this in any of the posts before, so I'll ask this now. What version of Apache are you using?
|
Quote:
|
All times are GMT -5. The time now is 09:46 PM. |