/
/
How to execute commands with alternate PHP versions

How to execute commands with alternate PHP versions

Why?

To execute commands and PHP scripts manually with alternate PHP handler and add them to CRON tasks.

Instructions

First of all, you have to locate interpreter of an alternate PHP version. To do that, navigate to the "Sites" section and a websites' settings that uses required PHP version, expand "Handler (PHP)" section and click on the "Copy" button near "Path to PHP interpreter" field.

 

Furthermore, you can find path to PHP interpreter in the field on the left in websites' settings.

 

Use this path before the command to execute it with alternate PHP version. For example, following command sends email using PHP 8.1 as alternate version:

/opt/php81/bin/php -r "mail([sender@example.com](mailto:recipient@example.com)','mail header','mail body’);

In this article