Changing Virtual Hosts Settings Using Configuration Templates
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
Important: 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:
- Create the
/usr/local/psa/admin/conf/templates/custom/ folder (if there is no such folder yet).
- Copy and paste the required templates from
custom/preserving the directory structure. You can find the complete list of templates and their descriptions in the Appendix B.
- Modify the templates. See the details in the Templates Execution Context section.
- Check that the modified templates are valid PHP files:
# php -l <file-name>
- Generate new configuration files:
# httpdmng <command>
Where <command> is one of the following:
--reconfigure-servergenerates sever-wide configuration files.
--reconfigure-allgenerates 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
- Copy the error pages template to the
# 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
- Edit the
- Check the validity of the file and generate new configuration files.
Leave your comments on this page
Leave your feedback or question on this documentation topic below. For technical assistance, contact your hosting service provider or submit a request to Plesk support. Suggest new features for Plesk here. Discuss general questions on the Plesk forum. All offtopic comments will be removed.