cPanel/WHM is a web-based control panel to manage a complete Linux operating system. All the cPanel accounts are created using one primary domain. This article will help you to change the document root for the primary domain of the cPanel user.
You must have root shell access for changing the main/primary domain document root in cPanel, Use the following steps to change the document root of your primary domain in the cPanel account.
You must have SSH access to root user to cPanel server.
Use SSH to get shell access for your server as root account, using your favorite ssh client. I have connected our server using PuTTY. Now edit following file.
Change USERNAME with your cPanel account name.
Change DOMAINNAME.COM with your Primary domain name.
After editing file, search for text documentroot and change path as per your requirements.
If your site is configured to run with ssl, then you also need to edit following file along with the step 1.
Edit file in text editor
and apply the same changes as above.
After making changed, we need to rebuild Apache configuration file and restart Apache server. Use following command to do it.
/scripts/rebuildhttpdconf service httpd restart
Your changes will be permanently updated. Check your site for reflecting changes.