Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I run RH 8.0 and have tried everything to get name based virtual hosting working. I've read countless HOWTOs, a book on Apache... you name it. Here's the pertinent portions of my (latest) httpd.conf file:
There is no default document set up, and you know the best part? It doesn't seem to matter if I change the order of the virtual hosts. Domain1.org *always* shows up first.
I had this problem when starting out with apache! Its really very frustrating... However, if my memory serves me correctly I have a solution for you. You need to change your configuration to the following:
Code:
Listen 80
#--> I dont know if u need the ServerName Directive or not, it depends on your situation.
NameVirtualHost 1.2.3.4 # --> I have no port number in my configuration
<VirtualHost 1.2.3.4:80> # Add the IP you want it to listen on, rather than *
ServerAdmin webmaster@domain1.org
ServerAlias *.domain1.org
DocumentRoot /var/www/html/domain1
ServerName domain1.org
DirectoryIndex index.php index.html
</VirtualHost>
<VirtualHost 1.2.3.4:80> # Add the IP you want it to listen on, rather than *
ServerAdmin webmaster@domain2.com
ServerAlias *.domain2.com
DocumentRoot /var/www/html/domain2
ServerName domain2.com
DirectoryIndex index.php index.html
</VirtualHost>
I hope that helps you/solves your problem, as that is similar to what I am using, and I am running about 10 virtual hosts.
Thanks for the reply, but that didn't work. Now I get the Apache Test Page for both domains.
I've seriously tried several different variants in using the IP, using the domain name, and using * in the NameVirtualHost directive, as well as using/dropping the port number. I feel like I must have it set up correctly. I'm wondering at this point if there's some strange, undocumented feature that Red Hat imposed on us like they did with sendmail, where it would only accept mail from localhost until you changed it.
OKAY, that's got it! Thank you both VERY much. I've posted my final config below for posterity. I did end up removing the port numbers, but I also replaced the IP with *. I may eventually do some testing to see whether I can get it working with the actual IP too, but for now I'm just going to relax and enjoy the fact that it's working. =)
Thanks again!
- Don
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@domain1.com
ServerAlias *.domain1.com
DocumentRoot /var/www/html/domain1
ServerName domain1.com
DirectoryIndex index.php index.html
<Directory "/var/www/html/domain1">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
ServerAdmin webmaster@domain2.org
ServerAlias *.domain2.org
DocumentRoot /var/www/html/domain2
ServerName domain2.org
DirectoryIndex index.php index.html
<Directory "/var/www/html/domain2">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Glad you got it sorted. Its a very strange and frustrating thing this problem. When I had it I ended up just fiddling round with those directives until it worked!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.