Knowledgebase
Knowledgebase
Custom Apache rules in cPanel
Posted by Ilya Vasilenko on 04 April 2022 01:02 PM

Customize Apache Virtual Hosts with Include Files

It is mandatory to use exactly following files/directories structure:

In the following examples:
  • Replace <user> with the account’s username.
  • Replace <domain> with the domain name.
  • Replace <include.conf> with the filename you like to to be, or leave as include.conf.

Scheme for an individual virtual host

  • SSL - /etc/apache2/conf.d/userdata/ssl/2_4/<user>/<domain>/include.conf
  • Non-SSL - /etc/apache2/conf.d/userdata/std/2_4/<user>/<domain>/include.conf

Scheme for all virtual hosts on your system

  • SSL

    • Exact Apache version 2.4 - /etc/apache2/conf.d/userdata/ssl/2_4/include.conf
    • Any Apache version - /etc/apache2/conf.d/userdata/ssl/include.conf
  • Non-SSL

    • Exact Apache version 2.4 - /etc/apache2/conf.d/userdata/std/2_4/include.conf
    • Any Apache version - /etc/apache2/conf.d/userdata/std/include.conf
  • SSl and Non-SSL and any Apache version - /etc/apache2/conf.d/userdata/include.conf

Scheme for all virtual hosts given user owns

  • SSL — /etc/apache2/conf.d/userdata/ssl/2_4/<user>/include.conf
  • Non-SSL — /etc/apache2/conf.d/userdata/std/2_4/<user>/include.conf

Rebuild Apache configuration and restart Apache

After you create or edit an Apache include userdata file, you must rebuild the httpd.conf file and restart Apache for the changes to take effect.

To rebuild the httpd.conf file, run:

/scripts/rebuildhttpdconf

To restart Apache, run:

service httpd restart
(1 vote(s))
Helpful
Not helpful