How to Change root directory from public_html for the main domain in cPanel

How to Change root directory from public_html for the main domain in cPanel

on cPanel by default the main domain name has public_html for the root directory, but can it be changed?

Sure, here is a guide on how to change root directory from public_html for the main domain in cPanel.

Edit the following files:

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

under documentroot set path to the new directory and save changes:

change root path DOMAIN.COM
change root path DOMAIN.COM

If your website uses SSL (and who doesn’t ) do the same for the following file:

/var/cpanel/userdata/USERNAME/DOMAIN.COM_SSL
change root path DOMAIN.COM_SSL
change root path 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

Run the following scripts to update any user data cache and rebuild apache configuration file

/scripts/updateuserdatacache
/scripts/rebuildhttpdconf

and finally restart Apache server to load changes.

service httpd restart
whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.