How does one host multiple sites from subfolders of public_html directory?

2 posts / 0 new
Last post
#1 Fri, 05/31/2019 - 17:11
dman2210

How does one host multiple sites from subfolders of public_html directory?

I have one main site, and several subdomains. I want to put my main site directly in public_html and each subsite into a different folder in public_html. What do I need to change to do that? How do I do it?

Fri, 05/31/2019 - 18:12
adamjedgar

Firstly, please forgive my very generic response here. I dont know your level of expertise in webhosting and mine is not extensive. I do however, know a bit about this and why I like the way Virtualmin does it concerning subdomains (it may be that my limited knowledge with htaccess customisations for subdomains is providing me with incorrect assumptions). However, below is my understanding of this topic...

First question i have...may i ask why you want to do it that way?

With the above in mind, here is why i personally would NOT want to do it that way!

As an Example, Centos Web Panel natively sets up subdomains using your method and i have problems with htaccess files in CWP as a result. For me its a downright pain in the backside...and particularly bad when one has client websites on shared hosting (thats just my experience BTW)

Essentially, what i have found is that the Primary Domain public_html directory htaccess file "has the potential" to take over all of the websites in the entire public_html directory. The way Virtualmin does it, this less of a problem because the subdomains are not in primary domain public html (as far as i understand it at least)

So what you are asking for is...

home/user/public_html/
- wordpress website 1/
- wordpress website 2/
- wordpress website 3//<code>
<br>

The .htaccess file in /home/user/public_html will apply to all of the wordpress websites above. That means as i far as i am aware, that any customisations and htaccess settings must consider this otherwise you will stuff all three websites if the htaccess file is incorrect (a dangerous option in my opinion)

Virtualmin on the other hand, sets up virtual sub servers using the following directory format

<code>home/user/
- public_html/wordpress website (for primary virtual server or domain)
- domains/wordpress website (for sub virtual server or subdomain)


Dont forget, the /home/user/"domains" directory does not exist until you have first created a Virtualmin/Sub server (virtualmin the automatically creates this).

To create virtual sub server do the following...

Create a primary Virtual Server (or domain using a Cpanel term)

  1. Virtualmin tab>Create Virtual Server

Then using the same method to create a sub server

  1. Virtualmin tab>Create Virtual Server> (only this time on the create virtual server page)

- ensure that you check "Sub-Server" option at the top LHS of page

  • Virtualmin should automatically assign the "Parent Server" for you

I have been building WordPress websites for almost 10 years now and have about 2 years with Virtualmin and various other control panels in Addition to Virtualmin (VestaCP, ISPConfig, CWP, Cyberpanel) My suggestion would be, if you want to have subdomain nesting "inside public_html" and all the websites are going to be WordPress ones, then i would strongly urge Wordpress Multisite. Just me and my experience level personally here, but that is by far the easiest way to do this and the easiest to administer.

If your websites are all going to use the same primary domain name, and are therefore just subfolders, and you are happy for them to essentially be the same website, then they will all use the same htaccess file and will reflect that in the URL in your browser (unless you mask using htacess in each of the subdirectories).

Now in the event that your websites URLs are supposed to be different domains, and all of the above doesnt change your mind...i think the following thread (particularly Jamies Comments) may be some additional worthwhile reading.

https://www.virtualmin.com/node/17907

https://www.virtualmin.com/node/10150

https://virtualmin.com/node/8667

https://virtualmin.com/node/24833

Please remember, this is just my limited experience in this area (particularly with CWP troubles because that panel does it a very similar way to what you ask) and it may be that this is just what works for my level of knowledge. More experienced users may not see any of the above as an issue for doing what you are after?

kind regards, Adam

AJECreative is the home of $5 webhosting, $15/month VPS servers (1cpu,1gb RAM, 25GB storage)
Centos7, Debian9, or Ubuntu18LTS
Available Control Panels = Centos-Webpanel, Cyberpanel, or Virtualmin

https://ajecreative.com.au