Question
How can I customize the Apache Virtual Host templates?
Answer
The following instructions can be used to create a new global template for all Apache virtual hosts.
Warning: If you misconfigure a custom template, Apache may generate an invalid httpd.conf file. This will result in a server that does not respond to HTTP requests. Be certain that you use caution when you create custom templates and create any directives that rely on specific Apache modules in the appropriate <IfModule> blocks. If you are unsure of what changes need to be made, please reach out to your System Administrator for advice.
- Connect to your server via SSH as the root user
- Make a copy of one or more of the following template files, depending on which template you need to change. Please note the names must be as they are shown below.
EasyApache 4 main template:cp -v /var/cpanel/templates/apache2_4/ea4_main.default /var/cpanel/templates/apache2_4/ea4_main.local
Apache 2.4 virtual host with SSL:cp -v /var/cpanel/templates/apache2_4/ssl_vhost.default /var/cpanel/templates/apache2_4/ssl_vhost.local
Apache 2.4 virtual host without SSL:cp -v /var/cpanel/templates/apache2_4/vhost.default /var/cpanel/templates/apache2_4/vhost.local
- Using your preferred text editor, make your changes to the ".local" file as required.
- Rebuild the Apache configuration. cPanel will treat the ".local" files with precedence over the default templates:
/usr/local/cpanel/scripts/rebuildhttpdconf
- Restart Apache:
/usr/local/cpanel/scripts/restartsrv_httpd
Additional Information
For more details and other ways of using Apache templates, please review the following:
cPanel Docs: Apache Custom Templates
Comments
0 comments
Article is closed for comments.