In this tutorial, you will learn how to change the cPanel documentroot for the main cPanel domain.
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
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:
In our example, we’ve modified the documentroot from /home/cPanelUsername/public_html to /home/cPanelUsername/zen/public
Tired of hassling with server management? ChemiCloud is the managed hosting solution designed to save you time and money! 🤓 Check out our web hosting plans!
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:
Step 4) Restart Apache:
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.