I have a wierd Problem. I want to set the document root of my machine to a certain folder, but somehow the document root changes to whatever virtual server is added.
What i mean is, if i add a virtual serve xyz.com on the hostname machine (something.machine.com)
something.machine.com pulls up xyz.com
Similarliy if i add a new server abc.com … now the hostname of the machine something.machine.com pulls up abc.com
… i dont want that to happen. What should i change in apache ? or any other thing ?
I believe this happens because Apache uses the first Virtual Host in the config file as the default if the hostname is not recognised.
As a work around add a virtual server for the hostname of the machine, and manually edit the apache directives for that host to include all names used to reference the machine. You can do this through virtualmin or if you don’t need to manage the virtualhost, you could just do this directly in the Apache module.
But see, shouldnt all the requests by default go to the default server in the Apache configuration that the installer sets up ?
Apache is kind of modal when it comes to virtual hosts…once it is being used for virtual hosting, you no longer have a single Document Root. The last VirtualHost listed in your httpd.conf becomes the “default” (though it is not specified as such in any way), and so you’ll want to create a virtual host for something.machine.com to catch those requests (it can have ServerAlias entries for any extra names you’d like the new host to catch).
Note that it doesn’t have to be a full-featured Virtualmin domain for things to work (but it can be).