Results 1 to 3 of 3
I'm trying to set up two virtual hosts. Here's my httpd config:
Code:
<Directory /Users/userX/dev/sandbox-2>
Order deny,allow
deny from All
Allow from localhost
</Directory>
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "/Users/userX/dev/sandbox-2"
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 05-25-2012 #1Just Joined!
- Join Date
- Aug 2010
- Posts
- 8
Apache httpd virtual hosts setup keep hitting the same VirtualHost
I'm trying to set up two virtual hosts. Here's my httpd config:
My problem is that, no matter which server name I try to access in my browser (blah or foobar) it'll serve from blah's DocumentRoot. However, if I were to comment out the the VirtualHost for blah, then it'll take me to foobar's DocumentRoot.Code:<Directory /Users/userX/dev/sandbox-2> Order deny,allow deny from All Allow from localhost </Directory> NameVirtualHost 127.0.0.1 <VirtualHost 127.0.0.1> DocumentRoot "/Users/userX/dev/sandbox-2" ServerName blah </VirtualHost> <VirtualHost 127.0.0.1> DocumentRoot "/Users/userX/dev/sandbox" ServerName foobar </VirtualHost>
I'm running apache2 on a mac osx if that makes a difference.
Thanks!
- 05-25-2012 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,685
try something like this:
Code:# default container NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "/var/www/html" ServerName localhost <Directory "/var/www/html"> Options FollowSymLinks AllowOverride None </Directory> </VirtualHost> # Virtual host 1 <VirtualHost *:80> DocumentRoot "/Users/userX/dev/sandbox" ServerName foobar <Directory "/Users/userX/dev/sandbox"> Options Indexes FollowSymlinks MultiViews AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> # virtual host 2 <VirtualHost *:80> DocumentRoot "/Users/userX/dev/sandbox-2" ServerName blah <Directory "/Users/userX/dev/sandbox-2"> Options Indexes FollowSymlinks MultiViews AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
- 05-25-2012 #3Just Joined!
- Join Date
- Aug 2010
- Posts
- 8
[Solved]
Thank you sir! That worked perfectly.
As for the config I posted, these were the errors: (Fixing these errors will make my config work)
There were multiple issues..
The biggest one is that I had a typo. (I had fooboar, not foobar)
Second, I need to include the port in NameVirtualHost as well as in
Also, what helped a lot while debugging this was start httpd in debug mode which is:
apachectl -e debug



