Hey,
I have a strange problem with the virtual hosts on my machine.
I have set one up for my domain (let's call it domain1.com) to accept connections on port 80 and its doc root is /var/www/websites/domain1/
Now, that one works when I go to domain1.com, but now if I go to the IP of the machine, instead of going to the default document root (/var/www/) is displays the document root of domain1.com (/var/www/websites/domain1/)
Im running centos5 32bit and apache2
I hope that makes sense :p
-
IIRC as soon as you enable virtual hosts, the first virtual host takes over the configuration of some of the defaults. For example ServerName and DocumentRoot get overwritten.
Just add another vhost to the beginning of your config and set the same properties as you had before:
<VirtualHost *:80> ServerName some.example.com DocumentRoot /var/www </VirtualHost> <VirtualHost *:80> ... </VirtualHost>
Edit:
I just had a look at your httpd.conf
as I think you want to use named virtual hosts (multiple host configurations on the same IP) you'll have to explicitly enable
NameVirtualHost *:80and then the VirtualHost directives should look the same as in my example:
<VirtualHost *:80> ...if you dont use named vhosts then anything served on a particular IP will come from the same virtual host configuration.
you might also want to have a look at the apache vhost documentation (http://httpd.apache.org/docs/current/vhosts/index.html) to get more familiar with the different concepts of name based vs. IP based vhosts and their respective advantages and drawbacks.
noobintraining : Thank you, I will give that a go :)Rob Olmos : Correct, first vhost is the primary/default for the IP/port.noobintraining : Thank you for your help, I shall have a looknoobintraining : I had a look and tried the suggestions, but it is still sending unhandled requests to domain1.com document root. I am also using webmin if this helpsnoobintraining : I havent had this problem before when I have setup virtual hosts with webmin, strange :sMarcel G : Can you post the new config, The one with the additions? Maybe we can figure out whats wrong.Marcel G : have you restarted apache after the modification... I didn't the last time I modified an apache conf, it took me quite some time to figure out why it still did not work :-)noobintraining : Yeah I have restarted apache and I tried restarting the whole server but to no avail :( I will post the conf once I have another bash at it :)noobintraining : Here is the conf after setting it up via webmin http://pastebin.com/B4QVhCQJ (domain1.com is substituted for my main domain). If I go to the IP it goes to the first virtual host and if I go to test.domain1.com it goes to the first virtual host too.From Marcel G
0 comments:
Post a Comment