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

To reduce the risk of errors during modification of configuration files, Plesk provides a mechanism for changing virtual host configuration -configuration templates. Before 11.0, Plesk had templates only for Apache configuration files, but with adding support for nginx administrators can modify nginx templates as well. Read more about the how Apache and nginx work together in the Administrator’s Guide, section Improving Web Server Performance with nginx (Linux).

Configuration templates are files based on which Plesk re-generates certain web server configuration files. Other configuration files are generated automatically and cannot be changed. The hierarchy of configuration files generated by Plesk automatically and from templates is shown in the Appendix A.

Web server configuration files support versioning. This allows you to roll back to a previous configuration if the new one contains errors. Plesk adds a file version number to the name of each configuration file. For example, virtual host configuration files located in the /var/www/vhosts/ <vhost_name> directories have the names like <version> _httpd.include. To quickly access the currently used configuration file of a virtual host, use the symbolic link last_httpd.include located in the same directory.

The default templates are located in /usr/local/psa/admin/conf/templates/default/.

Note: Do not change the default templates. To introduce your changes to the configuration, copy the templates you need to the /usr/local/psa/admin/conf/templates/custom/ directory and modify them, preserving the directory structure, and then modify these copies. You can create templates from scratch and place them in the custom/ directory according to the default structure.

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

To change virtual hosts configuration using configuration templates:

  1. Create the /usr/local/psa/admin/conf/templates/custom/ folder (if there is no such folder yet).

  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.

  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:

    • --reconfigure-server generates sever-wide configuration files.

    • --reconfigure-domain <domain-name> generates files for a specified domain.

    • --reconfigure-all generates all configuration files.

      Note: Plesk generates configuration files automatically upon a variety of events. For example, if a website’s hosting settings are changed - say PHP is enabled - configuration for this website is generated anew.

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.