How to apply new PHP handler to multiple domains via CLI


2016-11-16 13:03:35 UTC


2017-08-18 07:18:45 UTC


Was this article helpful?

Have more questions?

Submit a request

How to apply new PHP handler to multiple domains via CLI

Applicable to:

  • Plesk 12.5 for Linux


How to apply new php handler to multiple domains or to a certain domains only via CLI


  1. To see a list of registered PHP handlers on a Plesk server, run this command:

    # plesk bin php_handler --list
  2. Get the list of domains that need to be updated:

For all domains on a server:

    MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa -Ne"select name from domains where htype='vrt_hst'" > domains.txt

For only certain domains:

Save the list of domain names that need to be updated in domains.txt file

  1. Run the following command to update php handler for the domains from the list:
    # cat domains.txt | while read i; do plesk bin domain -u $i -php_handler_id plesk-php56-fastcgi ; done

Replace plesk-php56-fastcgi with any other required handler.

If different handlers assigned to the bunch of domains should be replaced with the other appropriate handlers , download the script from the attachment , and use the instructions below to run it:

  1. Unzip downloaded file on any folder and make sure you have file .

  2. Make the script executable:

    # chmod +x
  3. Make sure you have relevant handlers that you are going to replace:

    # plesk bin php_handler --list

    Edit pairs of lines 33 and 35, 38 and 40 with handler_name and new_handler_name handlers that you want to switch:

    if ($handler =~ m/^handler_name$/g) {
    `plesk bin domain -u $name -php_handler_id new_handler_name -nginx-serve-php true`;
  4. Run the script:

    # ./


Have more questions? Submit a request
Please sign in to leave a comment.