Modify virtualhost for single domain on cPanel(Apache 2.4)

Date Posted: 27-08-2017

Latest cPanel comes with apache 2.4 and if we want to edit particular domain virtualhost, this post explain on how to modify virtualhost for single domain.


  1. Centos 7
  2. cPanel/WHM installation.
  3. Server root ssh access.


Login to the server using ssh.

Create a directory a for user cPanel user.

mkdir -p /usr/local/apache/conf/userdata/std/2_4/username/domain.tld/


username – cPanel username

domain.tld – Your domain name

Create a config file and append your virtualhost change

vi /usr/local/apache/conf/userdata/std/2_4/username/domain.tld/virtualhost.conf

Append your virtualhost config change. In this post, we just adding DirectoryIndex

DirectoryIndex default.html index.html index.php

Execute the below command to add the custom config.

/scripts/ensure_vhost_includes --user=username

where, username is cPanel username

Verify the syntax of the included configuration. Please note that config should always error free and apache won’t start incase of error.


Restart the apache service.

service httpd restart


Leave a Reply