Changing Virtual Hosts Settings Using Apache Configuration Templates

You can change the settings of virtual hosts running on the Panel server, for example, set custom error pages (similar for all virtual hosts), or change the port on which the hosted site is available.

These settings are stored in a set of Apache and virtual hosts configuration files. To reduce the risk of errors during modification of Apache configuration files, Parallels Plesk Panel provides a mechanism for changing the Apache and virtual host configuration - Apache configuration templates. These templates are files, based on which Panel re-generates certain Apache configuration files. Other Apache configuration files are generated automatically and cannot be changed. The hierarchy of the Apache configuration files generated from Panel automatically and from templates is shown in the Appendix A: Apache Configuration Files.

Apache configuration files support versioning. This allows you to roll back to a previous configuration if the new one contains errors.

The default templates are located in $PRODUCT_ROOT/admin/conf/templates/default/, where the $PRODUCT_ROOT_D is /usr/local/psa for RPM-based systems or /opt/psa on DEB based systems.

To introduce your customizations to the configuration, copy the templates you need to the $PRODUCT_ROOT/admin/conf/templates/custom/ directory and modify them, preserving the directory structure, and then modify these copies. You can create new templates from scratch and place them in the custom/ directory according to the default structure.

Important: Do not change the default templates. All template customizations must be performed in the $PRODUCT_ROOT/admin/conf/templates/custom/ directory, and the default templates structure and content must be kept unchanged, since there are no specific tools to undo the changes.

To remove customizations and restore the default configuration, just delete the custom template files.

To change virtual hosts configuration using Apache configuration templates:

  1. (If there is no such directory yet) Create the $PRODUCT_ROOT/admin/conf/templates/custom/ folder.
  2. Copy and paste the required templates from default/ to custom/ preserving the directory structure. You can find the complete list of templates and their descriptions in the Appendix B: Apache Templates Structure.
  3. Modify the templates. See the details in the Templates Execution Context section.
  4. Check that the modified templates are valid PHP files:

    # php -l <file-name>

  5. Generate new configuration files:

    # httpdmng <command>

    Where <command> is one of the following:

Example: modifying error pages:

  1. Copy the error pages template to the custom/ directory:

    # mkdir -p /usr/local/psa/admin/conf/templates/custom/domain/service/

    # cp /usr/local/psa/admin/conf/templates/default/domain/service/errordocs.php /usr/local/psa/admin/conf/templates/custom/domain/service/errordocs.php

  2. Edit the /usr/local/psa/admin/conf/templates/custom/domain/service/errordocs.php file.
  3. Check the validity of the file and generate new configuration files.

In this section:

Template Execution Context

Example: Changing Default Apache Ports

Please send us your feedback on this help page.