Advanced Apache Configuration

Last modified: July 11, 2022


EasyApache 4 provides several ways for you to customize your Apache configuration.

  • Make certain that you only use the methods below to modify your Apache configuration. If you use a method that we do not support, cPanel & WHM and EasyApache 4 can overwrite your custom configuration.
  • We strongly recommend that you read the Apache Configuration documentation before you customize your Apache configuration.

How it works

EasyApache 4 builds your global Apache configuration from the following components:

  • Global templates — EasyApache 4 uses the global configuration templates in the /var/cpanel/templates/apache2_4/ directory to create your global Apache configuration.
  • The modules, options, and extensions that EasyApache 4 installs for Apache.

EasyApache builds each virtualhost tag from the following components:

  • Any custom templates in the /var/cpanel/templates/apache2_4/ directory.
  • Account information for each domain — When you make a configuration change to an account or domain in the cPanel or WHM interface, cPanel & WHM changes the content of the appropriate file in the /etc/apache2/conf.d/userdata/ directory.
  • Additional templates for each domain — EasyApache uses the files in the appropriate /etc/apache2/conf.d/userdata/ directory for each domain to build the configuration of each virtualhost tag.

Modify the Apache configuration options

htaccess files

When Apache processes a request, it searches for an .htaccess configuration file inside the directory that contains the requested file. If the .htaccess file exists and Apache can read it, Apache uses its contents to modify the configuration for the request. For more information about how to use .htaccess files, read Apache’s HTTP Server Tutorial.

Some events in the cPanel & WHM environment trigger a syntax check of a .htaccess file. When Apache runs the check, it skips any modules that it loads. Any attempt to reference configuration directives that these modules provide will produce syntax errors. To prevent these errors, you must wrap those directives within an <IfModule></IfModule> block. The following example displays an <IfModule></IfModule> block:

<IfModule mod_suphp.c>
    suPHP_ConfigPath /etc


On servers that run PHP-FPM, you cannot use the ErrorDocument directive unless you also set the ProxyErrorOverride directive to On for the specific virtual host. If you set the virtual host’s ProxyErrorOverride directive to On, the server’s error behavior will differ from servers that do not run PHP-FPM and those that do not set the ProxyErrorOverride directive.

We strongly recommend that you do not set the ProxyErrorOverride directive to On in a global include file. This may cause unexpected behavior.

For more information about PHP-FPM, read our PHP-FPM documentation.

Modify your global Apache configuration

To modify your global Apache configuration, use one or more of the following methods:

Modify the Apache configuration directives via WHM

To modify the Apache global configuration directives that cPanel & WHM builds by default, use WHM’s Global Configuration interface (WHM » Home » Service Configuration » Apache Configuration » Global Configuration).

Modify the Apache configuration files with include files via WHM

To modify the Apache configuration’s include files through WHM, use WHM’s Include Editor interface (WHM » Home » Service Configuration » Apache Configuration » Include Editor).

Modify the Apache configuration on the command line with new conf files

To modify the Apache configuration via the command line interface, create custom configuration files in the /etc/apache2/conf.d/ directory. Your new configuration files must use the .conf file extension to ensure that the system will recognize them. Also, your .conf files must possess root:root ownership and 0600 permissions.

After you modify, add, or remove a .conf file, you must restart the Apache service with the service httpd restart command.

Modify the content of specific virtual hosts

You can use the command line interface to add include files that modify the content of the virtual host containers in your Apache configuration. You may wish to do this to modify the configuration of an individual domain or a specific user’s domains. For more information about how to modify your virtual host containers with include files, read our Modify Apache Virtual Hosts with Include Files documentation.

Additional Documentation