Customizing Apache Virtual Host in httpd.conf Print

  • 5

In Apache 3+ the httpd.conf file is regularly rebuilt and custom changes are lost on a regular basis.

To support customization, Apache provides a method for overriding the default setting by including a custom (conf)ig file for each user account and domain.

If you look at the httpd.conf file, you will find with each virtual host a notation indicating the file path where your custom files can be stored. Example

< VirtualHost >
DocumentRoot /home/useracct/public_html
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/ combined
CustomLog /usr/local/apache/domlogs/ "%{%s}t %I .\n%{%s}t %O ."
## User useracct # Needed for Cpanel::ApacheConf
< IfModule mod_suphp.c >
suPHP_UserGroup useracct useracct
< / IfModule >
< IfModule !mod_disable_suexec.c >
SuexecUserGroup useracct useracct
< / IfModule >
ScriptAlias /cgi-bin/ /home/useracct/public_html/cgi-bin/

# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/useracct/*.conf"

< / VirtualHost >

Using the above example, you would create a file named "custom.conf" like so:


Once you have finished creating / updating your custom files, you will need to rebuild the httpd.conf:

/scripts/ensure_vhost_includes --all-users

For more information, please reference:


Was this answer helpful?

« Back