Applicable to:
- Plesk for Windows
Question
How to change PHP version for all domains in Plesk for Windows Server?
Answer
-
Connect to a Plesk server via RDP.
-
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
-
List all installed PHP handlers:
C:\> plesk bin php_handler --list
-
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:
-
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
-
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
Comments
4 comments
For Linux use this
where
<required_php_handler>
can be obtained by executing:@Miguel,
Hello! Thank you, I believe this will be helpful for other Pleskians.
We also have an article for Linux here: https://support.plesk.com/hc/en-us/articles/213933525
i want to execute the script with condition which is already have same php handler.
@Sathiya, Hi!
Please clarify what exactly do you want to achieve?
Please sign in to leave a comment.