Question
How to add additional PHP directives for a domain in Plesk via command line?
Resolution
For one domain
Connect to the server via SSH
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.inican be specified, using the same format as inphp.ini.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
- Connect to the server via SSH
- Create dom.list file with list of domains:
# plesk bin domain -l > dom.list
- Create
my_file_addfile with required setting. For example, withdisable_functionsdirective:disable_functions = "proc_open,proc_terminate,curl_exec,curl"
Run the utility in a loop for all domains from
dom.listfile:# cat dom.list |while read i; do plesk bin site --update-php-settings $i -additional-settings my_file_add; echo "$i - done"; done