Change the way Primary Domain Document Root works

eric.langley

Member
Mar 2, 2013
8
0
1
cPanel Access Level
Root Administrator
Hello All,

Testing cPanel, so far so good.

I have a question about setting up the primary domain and sub domain document roots.

I created an account and uploaded a site to it. Worked fine.
Then I added an addon domain and created a subdomain for it.

However cPanel put Document Root is inside my primary domains root folder. Not good. I know you can adjust Server Tweaks to allow putting sub domains above public_html but that is not what I want to do. I would like to have all of the domains have their own folder under public_html. Like this:

Primary Domain in /home/account/public_html/primarydomain
and all of the other domains as well
/home/account/public_html/anotherdomain
/home/account/public_html/site.anotherdomain

It's easy to add new sub domains like this but the primary domain is not created this way.

How can this be addressed?

TYIA,

~eric
 

quietFinn

Well-Known Member
Feb 4, 2006
1,222
87
178
Finland
cPanel Access Level
Root Administrator
You must edit the file:
/var/cpanel/userdata/USERNAME/DOMAIN.COM

and change the line:

documentroot: /home/USERNAME/public_html

to

documentroot: /home/USERNAME/public_html/DOMAIN.COM

and then run:

/scripts/rebuildhttpdconf
service httpd restart
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
Hello :)

You will need to manually modify the document root of the primary domain name associated with the cPanel account using the instructions in the previous post. The path to the file to edit is:

Code:
/var/cpanel/userdata/$username/$domain.com
Thank you.