WHM - Changing virtual host document root

Ron Mac Quarrie Apr 21, 2020

I was having a problem changing the document root through WHM/Cpanel. For some reason they will not allow it to happen from the WHM interface. I ran into several sites that said you have to create a special directory and files for handling VirtualHost containers. Following their directions I found they did not work using Includes in the httpd.conf file.

So, this is what worked for me.

  • WHM Version; v86.0.18
  • Operating system; CentOS 7

You will need root access to accomplish this task.

/var/cpanel/userdata/USERNAME/DOMAIN.COM
  1. Once you have opened the file, look for the following line:
documentroot: /home/USERNAME/public_html
  1. Modify the location according to your needs. Save it and exit.

  2. Rebuild the Apache conf and restart Apache:

/scripts/rebuildhttpdconf
service httpd restart

The change will be immediate. Simply clear your browser cache and force refresh the page!

This change will also remain after updates and when you make modifications via EasyApache... Hope this helps someone from a painful fix that is really quite easy.

Operating Systems