Friday, January 28, 2022

How to Change Document Root in WHM and cPanel for Specific Website

First, create a directory in your home directory. Give it the name 'backup'. Secondly, open the terminal in WHM. Then run the following command:

cp /var/cpanel/userdata/USERNAME/* /home/backup

Replace 'USERNAME' with the username of cPanel user that you would like to change its document root. The compand will simply copy all files in the directory "/var/cpanel/userdata/USERNAME" to the directory "/home/backup". The directory "/var/cpanel/userdata/USERNAME" contains configuration files for domains.

Suppose that the domain that you want to change its document root is 'example.com'. In this case, you need to open the file 'example.com' and 'example.com_SSL and edit document root using vim.

Finally, you need to run the following commands to restart apache:

/scripts/updateuserdatacache
/scripts/updateuserdomains
cp /etc/apache2/conf/httpd.conf{,.bak-`date +%Y%m%d`}
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd
For more information, check here