Question
How to change PHP version / handler for a domain or all domains?
Answer
-
Go to Domains > example.com > PHP Settings.
-
Select required PHP version and/or PHP handler from the drop-down list.
-
Apply the changes.
-
Connect to the Plesk server via SSH.
-
Generate a file with all domains:
# plesk bin site --list > domains.txt
-
(Optional) Open the file in a text editor and remove those domains that should not have their PHP version/handler changed.
-
List all installed PHP handlers:
# plesk bin php_handler --list
-
Change PHP version/handler for the domains listed in
domains.txt
file using the command below:Note: Replace
<php_handler>
with<id>
of a PHP handler from step 4.# cat domains.txt | while read i; do echo "[+] Updating domain: $i"; plesk bin domain -u $i -php_handler_id <php_handler>; done
In the example below, the command will assign Plesk PHP 8.3 served by PHP-FPM:
# cat domains.txt | while read i; do echo "[+] Updating domain: $i"; plesk bin domain -u $i -php_handler_id plesk-php83-fpm; done
To change the PHP version for all domains that use a specific PHP version, follow these steps:
-
Create a list with the names of all domains that use a particular PHP version (in this example, PHP 7.4 FastCGI):
# plesk db -sNe "select name from hosting h,domains dom where dom.id = h.dom_id and php = 'true' AND php_handler_id LIKE 'plesk-php74-cgi'" > domains.txt
-
Switch these domains to another PHP version (in this example, PHP 8.3 FastCGI):
# cat domains.txt | while read i; do echo "[+] Updating domain: $i"; plesk bin domain -u $i -php_handler_id plesk-php83-fpm; done
-
Connect to the Plesk server via RDP.
-
Generate a file with all domains:
C:> plesk bin site --list > C:domains.txt
-
(Optional) Open the file in a text editor and remove those domains that should not have their PHP version/handler changed.
-
List all installed PHP handlers:
# plesk bin php_handler --list
-
Change PHP version/handler for the domains listed in
domains.txt
file using the command below:Note: Replace
<php_handler>
with<id>
of a PHP handler from step 5.C:> for /f "tokens=*" %d in ('type C:domains.txt') do plesk bin domain -u %d -php_handler_id <php_handler>
In the example below, the command will assign Plesk PHP 8.3:
# for /f "tokens=*" %d in ('type C:domains.txt') do plesk bin domain -u %d -php_handler_id fastcgi-8.3
To change PHP version / handler for all domains that use a specific PHP version, follow these steps:
-
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…