The Document Root is the directory where the files for a particular domain or subdomain are stored on your server. By default, cPanel assigns a specific document root for each domain, typically within the public_html directory. Changing the document root can be useful if you want to point the domain to a different directory or manage multiple websites on the same hosting account.
In cPanel, you can modify the document root through the Addon Domains or Subdomains section. This flexibility allows you to configure different directories for different sites or environments (e.g., development vs. production). Changing the document root ensures that the domain or subdomain serves content from the correct folder.
Before changing the document root, make sure the new directory is properly configured and contains the necessary files for the domain. Incorrect configurations can result in the domain not displaying content correctly.
Steps to change the document root for a domain in cPanel:
- Log in to your cPanel account.
- Navigate to the Domains section.
- Click on Addon Domains if it's an addon domain or Subdomains if it's a subdomain.
The document root can be changed for both addon domains and subdomains. Ensure you select the correct domain type.
- Find the domain or subdomain you want to modify.
- Click on Document Root next to the domain or subdomain.
- Enter the new directory path where you want to store the files for this domain.
Make sure the new document root directory exists in your file structure or create it using the File Manager in cPanel.
Example new document root: Old: /public_html/mydomain/ New: /home/user/custom_directory/
- Click Save to apply the changes.
Once the document root is changed, the domain will load files from the new directory. Test the domain after making the change to ensure it works as expected.
- Verify that the change has taken effect by visiting the domain in a browser.
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.