Plesk

How to add additional PHP directives for a domain in Plesk using command line?

Question

How to add additional PHP directives for a domain in Plesk via command line?

Resolution

For one domain

  1. Connect to the server via SSH

  2. Create the file with all additional settings that will be applied to the domain (vi can be used or any other text editor, but this simple example shows single-line configuration file).
    For example, it is required to add the directive 'sendmail_path = "/dev/null"':

    # echo 'sendmail_path = "/dev/null"' > nomail.ini # this directive disables sending mail via PHP

    Note: any directive, which is valid in php.ini can be specified, using the same format as in php.ini .

  3. Apply the settings via the command:

    # plesk bin site --update-php-settings example.com -additional-settings nomail.ini

    It will give the same effect as if the contents of the specified file were copied to the Domains > example.com > PHP Settings > Additional configuration directives box in Plesk web GUI.

    Note: Each time this command is run, the previous settings will be overwritten.

For several domains at once

  1. Connect to the server via SSH
  2. Create dom.list file with list of domains:

    # plesk bin domain -l > dom.list

  3. Create my_file_add file with required setting. For example, with disable_functionsdirective:

    disable_functions = "proc_open,proc_terminate,curl_exec,curl"

  4. Run the utility in a loop for all domains from dom.list file:

    # cat dom.list |while read i; do plesk bin site --update-php-settings $i -additional-settings my_file_add; echo "$i - done"; done