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.

Prerequisites:

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

Implementation:

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/

where

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.

/scripts/verify_vhost_includes

Restart the apache service.

service httpd restart

 

Leave a Reply

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny