Editing Virtualhost Settings in WHM / cPanel
If you are using WHM and you try to edit your Virtualhost settings in your httpd.conf, you will find the following warning message:
# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.
This is not the most helpful warning message. Your first thought is probably that “the include files” refers to the pre_main, pre_virtualhost and post_virtualhost includes, but obviously they are no use when you are trying to edit the Virtualhost settings themselves.
Looking a bit closer inside the Virtualhost blocks in httpd.conf, the following advice is uncovered:
# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/username/domain.com/*.conf"
This helps a bit, but it’s still not especially clear what you need to do. For one thing this file doesn’t exist, and even if you create it the Include line is commented – and the whole point of this exercise is that the http.conf file cannot be manually edited so you can’t just uncomment it!
For anyone with this problem, hopefully the following should explain the full process needed.
First create the file mentioned inside the Virtualhost block. Note that this will be dependent on your username and domain so don’t just copy and paste the path below!
mkdir -p /usr/local/apache/conf/userdata/std/2/username/domain.com
Navigate to the directory you just created:
Create a configuration file using your editor of choice (filename must end in .conf), and add any settings you need:
Now to uncomment the include, run the following command:
This script will uncomment any Include lines in httpd.conf Virtualhost blocks where it finds at least one *.conf file in the relevant directory. It will restart Apache for you so no need to do that – your changes should be immediate.