To change document root of an account in cPanel

1. SSH into the server and go to
# /var/cpanel/userdata/USERNAME/DOMAIN.COM

2. Edit the file replacing 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

3. Now, look for Text Documentroot and edit these two lines to change the document root of your primary domain to now be a sub-directory inside “public_html” directory. The document root should look like this:
documentroot: /home/username/public_html/subdir
path: /home/username/public_html/subdir/cgi-bin

4. Save the file after the changes are made and then delete the cache file for your primary domain:
# rm -rf /var/cpanel/userdata/username/domain.com.cache

5. If the primary domain has an SSL certificate installed you will need to modify the following file in the same way as above:
# vi /var/cpanel/userdata/username/domain.com_SSL

6. After your changes are complete save the file and then delete the cache for your primary domain:
$ rm -vf /var/cpanel/userdata/username/domain.com_SSL.cache

7. After it’s done, you need to rebuild Apache and restart its server.
# /scripts/updateuserdatacache

# /scripts/rebuildhttpdconf
# service httpd restart

Hope it Helps!…

Leave a comment