1. Home
  2. Hosting Management
  3. Troubleshooting
  4. How to Change the cPanel DocumentRoot

How to Change the cPanel DocumentRoot

In this tutorial, you will learn how to change the cPanel documentroot for the main cPanel domain.

For this type of change, you will require root access to your server. If you don’t have root access, you will have to get in touch with your web host and see if they can do the change for you.

What is the Document Root Folder?

The document root is the folder where the website files for a domain name are stored. As you can host multiple domain names in cPanel (addon domains and subdomains), you need to have a unique folder for each domain. For the cPanel’s main domain, the document root is public_html and there isn’t any tool in cPanel that allows you to easily change the document root to something different.

How to Change the cPanel DocumentRoot

It’s strongly recommended to make backups of the files below before making any changes. Just in case something may go wrong.

Step 1)  Use nano or your preferred text editor to edit the files. Once the content of each file will open in the editor, you will have to update the “documentroot” value to the new path in the following files:

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

cPanel DocumentrootIn our example, we’ve modified the documentroot from /home/cPanelUsername/public_html to /home/cPanelUsername/zen/public

Step 2) The next step is to remove the existing cache files:

rm /var/cpanel/userdata/cPanelUsername/domain.tld.cache 
rm /var/cpanel/userdata/cPanelUsername/domain.tld_SSL.cache

Step 3) Rebuild the cache files and the Apache configuration file:

/scripts/updateuserdatacache
/scripts/rebuildhttpdconf

Step 4)  Restart Apache:

/scripts/restartsrv_httpd

After following the steps described in this tutorial, the primary domain of your cPanel account will be loading the content from the new documentroot that you’ve set.

Updated on February 4, 2021

Was this article helpful?

Related Articles

Need help?
We're always here for you. Submit a ticket or Chat with a live person.
Submit Ticket

Leave a Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.