Plesk

How to change PHP version for all domains in Plesk for Windows Server

Question

How to change PHP version for all domains in Plesk for Windows Server?

Answer

  1. Connect to a Plesk server via RDP.

  2. Start a command prompt as an Administrator.

  3. Create a list with the names of all domains with hosting:

    C:> plesk db -Ne "select name from domains where htype='vrt_hst'" > C:domains.txt

  4. List all installed PHP handlers:

    C:> plesk bin php_handler --list

  5. Run the following command:

    Note: Replace <php_handler> with <id> of a PHP handler from step 4, which will be used by all domains:

    C:> for /f "tokens=*" %d in ('type C:domains.txt') do plesk bin domain -u %d -php_handler_id <php_handler> 

 

To change PHP version for all domains that use a specific PHP version, apply the following steps:

  1. Create a list with the names of all domains that use a particular PHP version (in this example, PHP 5.6 FastCGI):

    C:> plesk db -sNe "select name from hosting hos,domains dom where dom.id = hos.dom_id and php = 'true' AND php_handler_id LIKE 'fastcgi-5.6'" > c:domains.txt

  2. Switch these domains to another PHP version (in this example, PHP 7.3 FastCGI):

    C:> for /f "tokens=*" %d in ('type C:domains.txt') do plesk bin domain -u %d -php_handler_id fastcgi-7.3