Page 1 of 1
still not getting <virtual hosts>
Posted: Sat May 14, 2005 6:41 am
by phpScott
I know this has been asked, heck I've asked but I still can't get it working. So lets dumb it down for me.
I have a WAMP set up.
XP home;
apache 2.x
php 5.x
mysql what ever the latest is.
They all work happily togther yeah.
in my http.conf file a have added a couple of virtual hosts like so.
NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerName scott
DocumentRoot E:/html
</VirtualHost>
<VirtualHost *:80>
ServerName phpMyAdmin
DocumentRoot E:/development/phpmyadmin
</VirtualHost>
I know you can add extra directives but this is the basics that are needed.
my doc root is set to E:/development
my servername is localhost:80
great it all looks good.
restart apache, restarts fine. no errors on restart.
whip open firefox go to
http://localhost and up comes my dummy page.
try
http://localhost/phpMyAdmin
404 error
try
http://localhost/scott
404 error
Any ideas why it doesn't work? if you need more info from my httpd.conf just ask.
Thanks Scott.
Posted: Sat May 14, 2005 8:42 am
by timvw
I know the manual mentions other options to configure them, but this is the way how i was able to get them to work... The Value after NameVirtualHost has to be the same in all the <VirtualHost> tags...
Code: Select all
NameVirtualhost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot "F:/websites/localhost"
<Directory "F:/websites/localhost">
AllowOverride All
Options All
</Directory>
</Virtualhost>
<VirtualHost *:80>
ServerName test
DocumentRoot "F:/websites/test"
<Directory "F:/websites/test">
AllowOverride All
Options All
</Directory>
</Virtualhost>
Posted: Sat May 14, 2005 10:20 am
by phpScott
I copied and pasted what you gave me, modified it for my directories.
Code: Select all
<VirtualHost *:80>
ServerName scott
DocumentRoot "E:/development/testing"
<Directory "E:/development/testing">
AllowOverride All
Options All
</Directory>
</Virtualhost>
<VirtualHost *:80>
ServerName turkey
DocumentRoot "E:/development/html"
<Directory "E:/development/html">
AllowOverride All
Options All
</Directory>
</Virtualhost>
in the error.log file it get this
Code: Select all
[Sat May 14 16:08:49 2005] [error] [client 127.0.0.1] File does not exist: E:/development/testing/turkey
[Sat May 14 16:08:49 2005] [error] [client 127.0.0.1] File does not exist: E:/development/testing/favicon.ico
the favicon.ico i get because it doens't exist but as you can see i have one servername called scott and another called turkey.
when I type
http://localhost into the browser i get is the index page for scott.
when I type in
http://localhost/turkey
i get 404 error.
if I go to my httpd.conf file and swith their order and restart apache then go to localhost I get the index page for turkey and
http://localhost/scott gives me a 404 error.
I thought the point of named virtual servers was that apache parsed out the name after localhost(servname) and followd the instructions in the virtual hosts to the directory specified.
or am i wrong.
It's not something stupid like what I am typing into the browser is it?
thanks.
Posted: Sat May 14, 2005 4:22 pm
by timvw
have you made sure they both resolve to 127.0.0.1?
the simplest to do that is editing C:\WINDOWS\system32\drivers\etc\hosts
Code: Select all
#
# example:
#
# 102.54.94.97 rhino.acme.com # bronserver
# 38.25.63.10 x.acme.com # x clienthost
127.0.0.1 localhost turckey scott
After that you should be able to surf to
http://turckey and
http://scott
Posted: Sun May 15, 2005 4:17 am
by phpScott
I knew it was something silly.
Now all I have to do is take care of a program that will take of updating both files for me.
Oh well so much for a haircut and dishes.
Cheers that worked a treat.
phpScott
Posted: Mon May 16, 2005 4:41 pm
by bokehman
Of course it doesn't work!
http://localhost/turkey is a sub directory of
http://localhost/ so it follows that the index file should be at E:/development/testing/turkey.