The cPanel accounts are created using a primary domain. All primary domains on the hosting account use “public_html” directory for all its website files and data. The sub-directories inside the public_html directory is occupied by the addon domains. The primary domain can also be setup to use a sub-directory inside public_html directory instead of public_html itself. Follow the below steps to change the document root of your primary domain in cPanel account. Please note that, you will need to have root SSH access to perform these steps.

1) Connect to your server via SSH as root user. You may follow the tutorial below, if you are using a Windows system to connect to your server via SSH. This tutorial explains how to use “Putty”, SSH client software to access server.

https://www.interserver.net/tips/kb/using-putty-to-ssh-to-server/

2) Using your favorite text editor (say vim) edit the following file.

$ vim /cpanel/userdata/username/domain.com

Replace the “username” with your cPanel account username and “domain.com” with your primary domain name and “subdir” with your new directory. Find the following two lines in this file.

documentroot: /home/username/public_html

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

Modify these two lines to change the document root of your primary domain to a sub-directory inside “public_html” directory.

documentroot: /home/username/public_html/subdir

path: /home/username/public_html/subdir/cgi-bin

Save the file after changes are made and then delete the cache file for your primary domain.

$ rm -vf /var/cpanel/userdata/username/domain.com.cache

3) If the primary domain has an SSL certificate installed, edit the following file the same way as above.

$ vim /var/cpanel/userdata/username/domain.com_SSL

Save the file after changes are made and then delete the cache file for your primary domain.

$ rm -vf /var/cpanel/userdata/username/domain.com_SSL.cache

4) Run the following scripts to update the user data cache and rebuild apache configuration file.

/scripts/updateuserdatacache

/scripts/rebuildhttpdconf

5) Restart Apache server to load changes.

$ service httpd restart