SOLVED Changing document root for primary domain does not work

kjdion84

Member
Apr 18, 2018
6
0
1
toronto
cPanel Access Level
Root Administrator
I've done the following:

nano /var/cpanel/userdata/username/mysite.com

Changed documentroot from /home/username/public_html to /home/username/public_html/mysite.com/public

rm -vf /var/cpanel/userdata/username/mysite.com.cache

/scripts/updateuserdatacache
/scripts/rebuildhttpdconf
service httpd restart

It DOES NOT WORK. It breaks the website entirely. Why???
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,215
363
Hello @kjdion84,

I used the following steps to successfully modify the default document root for a domain name:

1. Update the "documentroot" value to the new path in the following files:

/var/cpanel/userdata/username/domain.tld
/var/cpanel/userdata/username/domain.tld_SSL

2. Remove the existing cache files:

Code:
rm /var/cpanel/userdata/username/domain.tld.cache
rm /var/cpanel/userdata/username/domain.tld_SSL.cache
3. Rebuild the cache files and the Apache configuration file:

Code:
/scripts/updateuserdatacache
/scripts/rebuildhttpdconf
4. Restart Apache:

Code:
/scripts/restartsrv_httpd
It looks like you may not have restarted Apache. Can you let us know if that solves the issue?

Thank you.
 
  • Like
Reactions: DevWL and MaxFein

kjdion84

Member
Apr 18, 2018
6
0
1
toronto
cPanel Access Level
Root Administrator
OK so it works if I use:

/home/username/public_html/public

Instead of:

/home/username/public_html/mysite.com/public

Is there a way to make it work with the second example? Does the period need to be escaped or something?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,215
363
Hello @kjdion84,

I couldn't reproduce the issue when following the instructions noted in my previous response and using a directory name with a period as the document root. EX:

Code:
documentroot: /home/username/public_html/testing.directory/123
It's possible the "nano" command-line editor is the culprit here. Can you try using "vi" instead of "nano" to see if you notice a difference in the behavior?

Thank you.
 

kamm

Well-Known Member
Jan 17, 2004
51
1
158
Spain
cPanel Access Level
Root Administrator
Hello @kjdion84,

I used the following steps to successfully modify the default document root for a domain name:

1. Update the "documentroot" value to the new path in the following files:

/var/cpanel/userdata/username/domain.tld
/var/cpanel/userdata/username/domain.tld_SSL

2. Remove the existing cache files:

Code:
rm /var/cpanel/userdata/username/domain.tld.cache
rm /var/cpanel/userdata/username/domain.tld_SSL.cache
3. Rebuild the cache files and the Apache configuration file:

Code:
/scripts/updateuserdatacache
/scripts/rebuildhttpdconf
4. Restart Apache:

Code:
/scripts/restartsrv_httpd
It looks like you may not have restarted Apache. Can you let us know if that solves the issue?

Thank you.
Thanks for this info.

This post has similar instructions:
Editing a DocumentRoot problem
but it includes
Code:
/scripts/updateuserdomains
Is that necessary?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,215
363
Hi @kamm,

My testing shows that running the /scripts/updateuserdomains command is not necessary. The /scripts/updateuserdatacache command is sufficient to update the userdata cache files.

Thank you.
 
  • Like
Reactions: kamm