How to run PHP scripts on Plesk with different versions of PHP?
As it is possible to install multiple PHP versions via Plesk Installer, there is an option to work with all of them via the command line. All custom PHP handlers provided by Plesk are located in
/opt/plesk/php/. Here are some examples on how to run and use it via SSH:
Checking the version:
# /opt/plesk/php/5.6/bin/php -v
PHP 5.6.37 (cli) (built: Jul 20 2018 13:16:49)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v6.0.7, Copyright (c) 2002-2016, by ionCube Ltd.
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
Executing a command:
# /opt/plesk/php/5.6/bin/php -r command
# /opt/plesk/php/5.6/bin/php -r ‘$curl = curl_init(“https://example.com”);curl_setopt_array($curl, [CURLOPT_CUSTOMREQUEST => “HEAD”, CURLOPT_NOBODY => true, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_HEADER => true]);echo curl_exec($curl);’
Executing a script:
# /opt/plesk/php/5.6/bin/php -q script.php