Change default public_html/website folder location

OS type and version AlmaLinux 9.3
Webmin version 2.101
Virtualmin version 7.8.2
Related packages Subdomain

I am now able to create subdomains (thanks to Joe). I would like to change the default location of the public_html/website folder
from /home/< user >/public_html/< subdomain >
to /home/< user >/public_html/customfolder/

I tried to checkout the sub server template but could not find anything related to this. It would have been great if like cPanel, I could type in the correct location or be able to change it through the templates rather then a hardcoded location, is this possible?

Would appreciate if someone could help with this please.

after creation go to

webmin->servers->apache web server

choose the subdomain you want to change
click edit directives

change the 2 arrowed lines to where ever you want to serve from then save the file & restart apache

Thanks @jimr1 I have done these changes after doing the update of folder manually. I was hoping if the Virtualmin team can fix this issue going forward as it is a bug. I was hoping if they could also allow for a cPanel like input field to provide such path on subdomain/subserver creation as well.

Its not a bug it’s just a different way of doing things I prefer the way virtualmin does it rather than just being the same as cpanel

I have no experience with subdomains via Virtualmin, so this idea may not work — check out the setting – Virtualmin – System Settings – Virtualmin Configuration – then chose from the pulldown – Defaults For New Domains

the top two items are – Home Directory Base and Home SubDirectory — of course this is a global change affecting your entire linux server.

also I just found – Server Templates (again under Virtualmin – System Settings) – in there, for a specific template (you may wish to make a new one instead of editing the default) is the pulldown section – Website For Domain – in there it appears you can customize quite a bit of the apache config !!

@Joe / @Jamie - is there anywhere I can make a manual change so that the default location of the subdomain public_html folder is different. I wan the following:

from /home/< user >/public_html/< subdomain >
to /home/< user >/public_html/myfolder/< subdomain >

I see that this area of the subdomain customisation is not visible in the subserver templates, possibly because this is a special case for subdomains only and does not apply to subservers. It would have been great to expose an input for this path/directory to input at the time of subdomain creation or maybe through API when creating subdomains.

You’re really going to great lengths to do weird stuff that’ll continue to haunt you forever. But…

Manual changes can be done in the Apache config files in the VirtualHost sections (search for the current path). Virtualmin won’t alter it in the general case. The only cases I can think of where it’d be undone is if you disable the website or account and then re-enable it.

Be aware that making this change will confuse Virtualmin a bit, because it also keeps a record of where the public_html directory is in it’s own config. Right now there’s no well-supported way to use the type of path you mentioned, but in theory we could add it…

1 Like

Not to mention existing users (and please if you make the change) don’t forget all of us who don’t use Apache!

I also can’t see the point of making Virtualmin work more like cPanel.

Understood and yes it makes sense.

The use case was more about how I have already engineered my existing web apps so far with about 20+ subdomains. So wanted to maintain same structure while migrating to virtualmin with least amount of change. I was checking whether this type of customisation is something being developed in the pipeline.

Current structure:


Of course moving the subdomains one level up is not a big issue and I can live with that. Of course over time, I will adjust my app to be more dynamic instead of hardcoding the shared structure as I have right now.

Hope this helps.

Thank you for your feedback and support on all my issues. I have gained huge amount of confidence with virtualmin and I am a little upset with myself as to why I didn’t use virtualmin earlier.

Ok, in the next release it will be possible to use this kind of path for sub-domains with an API command like virtualmin modify-web --domain --move-subprefix subs/d1

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.