Change document root for primary domain in cPanel/WHM

This article will explain how to get change root document for your primary domain. You need to have root access to change the main/primary domain document root in cPanel, Use following steps to change document root of your primary domain in cPanel/whm.

Once you login through SSH edit the following file:

/var/cpanel/userdata/USERNAME/DOMAIN.COM

Replace USERNAME and DOMAIN.COM with your actual info.

Find these two lines:

documentroot: /home/USERNAME/public_html

path: /home/USERNAME/public_html/cgi-bin

And, edit them accordingly:

documentroot: /home/USERNAME/public_html/NEW_PATH

path: /home/USERNAME/public_html/NEW_PATH/cgi-bin

Save file, and delete the cache file for that domain:

rm -fv /var/cpanel/userdata/USERNAME/DOMAIN.COM.cache

If your domain has an SSL certificate installed, edit the below file in the same way as above:

/var/cpanel/userdata/USERNAME/DOMAIN.COM_SSL

And, delete the cache file:

/var/cpanel/userdata/USERNAME/DOMAIN.COM_SSL.cache

Finally, When finished editing the document root, run the following commands:

/scripts/updateuserdatacache
Service httpd restart

That’s all. Check your site for reflecting changes.