“default” server doesn’t really make sense once you have virtual hosts configured. With virtual hosts, it selects the best match, and then falls back to the first one configured (but determining which is “first”, and even which is the “best match” in the configurations can be challenging depending on whether you have anything configured in the httpd.conf or in the vhosts directory). On Ubuntu, you usually just need to make sure your “default” virtual server is the first one read (so name it in such a way that it will be).
But, it may still surprise you. If you try to intermingle *:80 with <ip>:80 sites, it won’t work the way you expect (this is in the FAQ/troubleshooting docs for Virtualmin). So, you need to pick one or the other. The 000-default.conf or whatever it’s called on Ubuntu probably uses *:80 and maybe *:443. Fix that, and things will be more predictable.
But, I’d advise you not try to think about anything in a virtual hosting system as “default”. Give everything you want to be accessible a hostname and an IP in their own VirtualHost section.
Hi again – thanks so much for your generous time in helping me.
when installing VM, a hostname is required to be defined, and I used www.myweb.com (not the real hostname, but I use it for explanation purpose)
If i do not create any new virtual servers, and I visit www.myweb.com, it displays the html pages located in /var/www/html (and a default html page is created automatically).
so far – so good – I want it like that
Now if i create 2 virtual servers (abc.com and xyz.com)…
Virtualmin will create their separate directories as follows:
/home/abc
/home/xyz
The problem is that when I lookup the hostname defined during installation (myweb.com) it now no longer routes to /var/www/html as it did initially
instead it goes to /home/abc … and displays the html pages I created for the first virtual server I created “after” Virtualmin installation.
I need it to stay in /var/www/html which is where it goes if I do not create a new virtual server.
how can I correct this?
Forgive me if the answer is contained in your original reply — I am new to this.
What I do most often (and probably the easiest way for you) is to create a separate virtual host for your hostname. Or you can modify Apache/Nginx config directly to add a server block for your hostname and make the default document root to /var.
Joe’s right, unless you specifically configure a document root location for your hostname, it would always point to the first virtual host you created in Virtualmin.
I followed your advise and it worked fine now.
It initially gave me an error, but I refreshed the page and all is well.
Thank you so much – I appreciate your help
In my case, I find this software wonderful. It serves my need.
I cant wait to learn it at a more advance level.
Apache just doesn’t work that way. It is either in VirtualHost mode, or not. Once it’s got Virtualmin domains, it is in VirtualHost mode. So, if you want a “default” site, you need to create a VirtualHost that is whatever “default” you want and make sure it is the first one Apache reads, as explained above. No amount of wishing will make Apache work differently than it does…so, don’t think about “default” sites anymore, because that’s not how Apache thinks about it. When you have VirtualHosts, Apache uses its own logic to determine what to show, and it’s not always intuitive (“default” is not a word Apache knows, but the first VirtualHost it reads will be what it serves if nothing matches the request better, which kinda looks like a “default” if you squint).