A lot of clients ask us if they can host a subdomain on a separate cPanel domain.
The answer is YES, you can have a separate cPanel account for your subdomain.
Normally, you can create your subdomains in cPanel->Subdomains->Create a Subdomain. See our article on How to create/delete subdomains in cPanel.
But, as we said, you can have a separate cPanel account. Just follow the normal steps for creating a new cPanel account in WHM, and instead of the main domain, enter the subdomain. See the image:
Be sure the subdomain doesn’t exist on the server. Otherwise, you will not be able to create it in WHM.
Notice that you can also host your subdomain on another host. To do so:
1. Create the account for the subdomain on the other host.
2. Edit the DNS settings for the main domain and add a record like:
Hi,
This is very interesting.
Here is my situation: I have an account with the main domain :
CPANEL ACCOUNT mydomain : mydomain.com
And I need two subdomains to live on an other account. The first one works without problem when I create the account but when I add a domain with the other subdomain I get an error :
CPANEL ACCOUNT subdomain1 : subdomain1.mydomain.com. <– OK
ADDON DOMAIN subdomain2 : subdomain2.mydomain.com. <–ERROR (domain exists…)
So Now you're saying that If I make my main cpanel account Reseller (mydomain.com) and give it ownership of my second cpanel account (subdomain1.mydomain.com.) I can create a subdomain on my main account that points to the other account's website documentroot?
If so, Do I need to go edit the documentroot into /var/cpanel/userdata/mydomain/subdomain2.mydomain.com like that :
from
/home/mydomain/public_html
to
/home/subdomain2/public_html
Does the fact that the main account is a reseller that have ownership to the other cpanel account will make it work even if this document root is outside of the main account's home folder ?
Or maybe I understood it all wrong?
Thanks for your help.
Hello,
For the second account, just create another cPanel account (not an add-on domain)
Main domain – /home/mydomain/public_html/
Sub1 – /home/subdomain1/public_html/
Sub2 – /home/subdomain2/public_html/
You can have all 3 on the same reseller account. (mydomain for example)
We do not suggest editing documentroot .
Yes, there is an option to create subdomains across domains, but it’s not recommended. The updated link is https://docs.cpanel.net/whm/server-configuration/tweak-settings/#domains
Hi, Thanks for your answer.
The problem is that both subdomains needs to be on the same account, as it is used for multilang purposes.
Is there any way to make that work ?
Thanks!
Hello,
You should read the docs and test these two options in WHM
Allow cPanel users to create subdomains across accounts
Allow WHM users to create subdomains across accounts
https://docs.cpanel.net/whm/server-configuration/tweak-settings/#domains
Thanks for your help. This will do it.
For the record : After reading I understand that the security risk does not really matters for me because there is only one human managing every cpanel accounts ont this server. Also, because the tweak settings are only to “allow creation of subdomains between accounts” and not to “have subdomains between accounts”, after the subdomain is created, I probably could juste put the tweak settings back to OFF.
Thanks again!
Hello, this is how we add an account that is, itself, a sub-domain of another domain set under another account. But we have trouble adding an add-on domain to that account; error: the domain (main domain) “is already owned by another user”.
In other words:
– in account #1: user ‘domain’ owns account ‘domain.com’;
– in account #2: user ‘anotheruser’ owns account ‘sub1.domain.com’;
– in account #2: unable to add add-on domain ‘sub2.domain.com’ because ‘domain.com is owned by user “domain”‘.
Is there a solution to this? Or another, better recommended way to achieve this? Thanks!
Hello. A solution can be of course to create another cPanel account for sub2.domain.com And if you want the same user to manage both subdomains (sub1 & sub2) you can give reseller privileges.
Another solution is to enable this option in WHM https://documentation.cpanel.net/display/68Docs/Tweak+Settings+-+Domains#TweakSettings-Domains-AllowcPaneluserstocreatesubdomainsacrossaccounts .. Notice the warning “Do not enable this option. It can cause serious security issues.”
This solution will allow you to create sub2.domain.com on the ‘anotheruser'(sub1.domain.com) account.
I hope this helps.
I want to double-check on this — so as long as you don’t create the subdomain in your cPanel area for the domain (mydomain.com)… instead you create a name like devsite.mydomain.com in the whm’s Create a New Account? That way the subdomain doesn’t exist on the server yet… Do I have that right?