Skip to content

Instantly share code, notes, and snippets.

@georgeyord
Created March 12, 2014 07:53
Show Gist options
  • Save georgeyord/9502606 to your computer and use it in GitHub Desktop.
Save georgeyord/9502606 to your computer and use it in GitHub Desktop.
Change the Primary Document Root in cPanel/WHM
For changing the main/primary domain, you will need to have root SSH access and be able to edit the following files (replacing your user & domain info):
/var/cpanel/userdata/USERNAME/DOMAIN.COM (replace USERNAME and DOMAIN.COM with actual info).
In that file, 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/SUBDIR
path: /home/USERNAME/public_html/SUBDIR/cgi-bin
Save file, and then delete cache file for that domain:
rm -fv /var/cpanel/userdata/USERNAME/DOMAIN.COM.cache
If domain has SSL certificate installed, you would have to do the same for:
/var/cpanel/userdata/USERNAME/DOMAIN.COM_SSL
And, delete:
/var/cpanel/userdata/USERNAME/DOMAIN.COM_SSL.cache
Run these two scripts:
/scripts/updateuserdatacache
/scripts/rebuildhttpdconf
Restart Apache, and that should do it.
REF:
http://forums.asmallorange.com/topic/16797-best-method-of-changing-the-document-root-of-your-primary-domain/
http://blog.servint.net/2012/03/30/the-tech-bench-changing-a-document-root-in-cpanel/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment