Plesk

How to add additional Apache directives globally on a Plesk server?

Question

How to add additional Apache directives by service plan or globally, so that these directives will not be overwritten by an update?

Answer

The following steps apply to each Service Plan individually. For server wide solution follow the steps from the SSH Terminal section below:

  1. Log into Plesk

  2. Go to Service Plans > Example Plan > Web Server > Additional Apache directives

  3. Enter the desired directives in the Additional directives for HTTP and Additional directives for HTTPS fields

  4. Scroll down and click on Update & Sync

    Note: All newly created domains will receive the specified settings. Existing domains will not be updated. Additional directives set for already existing domains should be changed on a per-domain basis.

SSH Terminal - Server wide solution

  1. Connect to the server via SSH

  2. Create a configuration file for the directives:

    • Debian-based OS (e.g. Ubuntu, Debian):

      # vi /etc/apache2/conf-enabled/zz011_custom_directives.conf

    • RHEL-based OS (e.g. CentOS, RedHat):

      # vi /etc/httpd/conf.d/zz011_custom_directives.conf

    Note: Apache loads configuration files in alphabetical order, so if it's required to overwrite some values managed by Plesk, make sure the new custom config file is loaded after zz010_psa_httpd.conf. For example by naming it as zz011_custom_directives.conf

  3. Add the desired Apache directives to the newly created file and save the changes

  4. Check if the Apache configuration is correct by executing this command:

    # apachectl configtest

    Expected output:

    # Syntax OK

  5. Restart Apache by executing this command:

    • Debian-based OS:

      # systemctl restart apache2

    • RHEL-based OS:

      # systemctl restart httpd

Exit mobile version