Custom virtual host Apache configuration for CPanel/WHM

Here’s how I applied some custom virtual host configuration for a CPanel account. Note that you need to have root access to the box. (Or get your hosting company to do it for you)

Example user: foobar
Example domain:

Create the directory structure/usr/local/apache/conf/userdata/std/2/foobar/

std = standard config (ssl for secure hosts)
2 = major version number of apache
foobar = username of the account = domain of the account

Create a vhost.conf file. The file can be any name, but must have the .conf extension. In this file put the override config. For example:

  DocumentRoot /home/foobar/newrooot
  CustomLog /home/foobar/logs/foobar.log combined

Note the lack of the opening and closing directives.