Web Server

Integrating with the web server via the Plesk SDK API gives your extensions the ability to customize web server configuration files and perform web server reconfiguration. Custom configuration is injected via hooks of pm_Hook_ApacheWebConfig (when Apache is used as the web server), pm_Hook_NginxWebConfig (when nginx is used as the main web server and not a proxy), and pm_Hook_IisWebConfig (for IIS web servers).

Adding Custom Configuration

On reconfiguration, the web service will be called by hooks of the getDomain<ServerType>Config method, which will introduce the custom configuration:

  • getDomainApacheConfig(pm_Domain $domain) - returns the string which will be added to the Apache configuration as a <VirtualHost></VirtualHost> custom directive.
  • getDomainNginxConfig(pm_Domain $domain) - returns the string which will be added to nginx configuration as a {...} custom directive.
  • getDomainIisConfig(pm_Domain $domain) - returns XML as a string which will be added to the Plesk IIS configurator.

Every time the domain is reconfigured, these methods will be called.

Reconfiguring Domains

An extension can reconfigure the domain web server. For example, the git extension should reconfigure the domain when creating a "push" repository with HTTP access.

$webServerManager = new \pm_WebServer();
$webServerManager->updateDomainConfiguration(new \pm_Domain(1));

Apache hook example

class Modules_Git_ApacheWebConfig extends pm_Hook_ApacheWebConfig
    public function getDomainConfig(pm_Domain $domain)
        return '# domain name:' . $domain->getName();

IIS hook example

public function getDomainConfig(pm_Domain $domain)
    $repositoriesPath = Repository::getDomainRepositoryPath($domain);
    return "<git enabled=\"true\" reposPath=\"{$repositoriesPath}\" />";


Leave your feedback on this topic here

If you have questions or need support, please visit the Plesk forum or contact your hosting provider.
The comments below are for feedback on the documentation only. No timely answers or help will be provided.