After creating a new Virtual Server, the website doesn't show contents of public_html, rather it shows var/www/html which I don't want

I’ve set up a new Virtual Server, but I’m encountering an issue with the default web directory. Currently, the server is displaying content from the /var/www/html directory, when I actually want it to display content from the public_html directory. Even though Virtualmin’s interface suggests public_html should be the default directory, this isn’t happening. Can you help me understand why this is occurring and how to configure the server to use public_html instead?

SYSTEM INFORMATION
OS type and version Ubuntu Linux 24.04.1
Virtualmin version 7.30.3

This makes no sense. What does this look like?
You sure you’re not just seeing the default page?

My directory structure is almost identical to yours, with one key difference: I have a nested ‘public’ folder inside the ‘public_html’ directory. This additional folder exists because I installed CodeIgniter 4, a PHP framework that requires this specific directory structure for serving web content.

And even before installing Codeigniter 4, public_html was the default. But the website’s showing the /var/www/html contents instead.

Have you posted content? Is their a proper index file? What makes you think you are seeing something in /var/… ?

Becaues I’m seeing the “Apache2 Default Page” which is located in var/www/html.

Is this a new virtualmin install on a previously unconfigured system or is this a recent behavior on an old system?

it’s a new virtualmin install, yes.

In that column posted earlier there is a preview website button. What does it show?

When I try to access my subdomain through the Virtualmin interface, it redirects me to a non-working link that looks like this (with my private information redacted): “https://virtualmin.mydomain.com/virtual-server/link.cgi/192.***.**.**/http://www.mysubdomain.mydomain.com/

I believe the interface is attempting to redirect me to http://www.mysubdomain.mydomain.com/. When I manually enter this address in my browser, it displays the default Apache2 welcome page that comes with Ubuntu server installations.

You didn’t answer this.

We need to know you ran the script in the documentation on a fresh OS install that WASN’T previously configured. I’m not trying to be difficult but we need to know you didn’t install on a system already configured. This should work out of the box.

Sorry, yes I installed a fresh installation of Ubuntu Server prior to installing Virtualmin.

OK. That’s about where my knowledge ends then. :frowning:

You talk ‘sub domain’. Is the main set up and working?

Nope. Virtualmin, the control panel, is run on a sub-domain as well.
Soimething like this:
Virtualmin control panel @ vmDOTmydomain.com
New virtual server website @ websiteDOTmydomain.com
nothing @ mydomainDOTcom

So you’re saying that the new virtual server website SHOULD be showing the contents of public_html instead of /var/www/html, correct?

You’re setup seems strange to me, or at least the way I set things up. I set up a ‘top-level server’. If I want a separate structure for the ‘sub’ I set up a ‘sub server’.

I’ve only done this where I have Discourse forum software (docker) running. I don’t know it is the ‘right way’ but it works.

If I remember correctly you will get problems with DNS otherwise.

Hmm… I see that. What’s the difference between a top-level-server and a sub-server? Does it relate to domains and sub-domains at all?

Maybe I’ll try deleting my current virtual server and redoing it with mydomain.com instead of website.mydomain.com.

How do I delete my first virtual server? I can’t seem to find anything regarding “Delete” anywhere.

The DNS is handled by the top level server, I think. So trying to add a second top level server with the same domain name is probably an issue.

But, I’m out for the night. Good luck. You might have to wait a bit until someone more knowledgeable shows up. :frowning:

No problem, thanks for trying to help! Happy new year~

1 Like

That’s an unusual problem. Normally Apache is either configured to serve VirtualHosts or it is configured to serve the “default” website (the one in /var/www). I’ve seen this occur in the past when people installed some web application from the Debian/Ubuntu repositories, as some packages include some web server configuration that overrides the usual config file.

So, if you installed any web application using apt, you should remove it, and install it instead into a Virtualmin domain (again, Apache can either host one website or many VirtualHosts, and the web app packages in the apt repos expect the former case). If you followed any documentation that included setting up Apache to serve anything outside of a VirtualHost, you need to undo that. As, once again, Apache can do one or the other, it can’t do both. In a virtual hosting environment, everything you serve should be configured inside a VirtualHost section.

If none of that sounds right, we’ll need to see what changes you’ve made to the Apache configuration files, so we can spot the trouble.