LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Apache Virtual Host Problem (https://www.linuxquestions.org/questions/linux-newbie-8/apache-virtual-host-problem-304339/)

eckertc1 03-21-2005 11:19 AM

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.

evil_empire 03-21-2005 01:07 PM

And have you configured the DNS appropriately?

eckertc1 03-21-2005 01:17 PM

im assuming so since it does work at least half the time.

Fredstar 03-21-2005 03:06 PM

Quote:

Originally posted by evil_empire
And have you configured the DNS appropriately?
Yes with my DNS host. If thats what you mean. All domains are pointing to my actual ip address.

As for internal DNS i was under the impression that you do not need to set up internal DNS for apache?

looseCannon 03-21-2005 03:22 PM

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.

eckertc1 03-21-2005 03:29 PM

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

eckertc1 03-21-2005 04:51 PM

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

eckertc1 03-22-2005 06:06 AM

bump

evil_empire 03-22-2005 12:20 PM

Well, I would still suggest, use the DNS approach.

Fredstar 03-22-2005 09:03 PM

Quote:

Originally posted by evil_empire
Well, I would still suggest, use the DNS approach.

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

looseCannon 03-23-2005 07:12 AM

I didn't see this in any of the posts before, so I'll ask this now. What version of Apache are you using?

Fredstar 03-23-2005 03:31 PM

Quote:

Originally posted by looseCannon
I didn't see this in any of the posts before, so I'll ask this now. What version of Apache are you using?
Apache 2.0


All times are GMT -5. The time now is 09:46 PM.