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 10.0.0.1:80 >
ServerName your-website.com
ServerAlias www.your-website.com
DocumentRoot /home/useracct/public_html
ServerAdmin webmaster@your-website.com
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/your-website.com combined
CustomLog /usr/local/apache/domlogs/your-website.com-bytes_log "%{%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/your-website.com/*.conf"

< / VirtualHost >

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

/usr/local/apache/conf/userdata/std/2/useracct/your-website.com/custom.conf

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

/scripts/verify_vhost_includes
/scripts/ensure_vhost_includes --all-users

For more information, please reference:
http://www.cpanel.net/documentation/easyapache/customdirectives.html

/scripts/verify_vhost_includes

Was this answer helpful?

« Back