2.8.7. Change PHP version for console

Attention!

Changing the PHP version for console does not affect the PHP version of the site. For the site, use the instruction Change PHP version for site.

Command to see the current version of PHP:

php -v
Affects all new connections via SSH.
  1. Open the "Hosting account settings" section (or "Hosting → Hosting account settings").
  2. In the "PHP version" block, select the desired version and click "Change":
  3. Run the command source ~/.bashrc or . ~/.bashrc or simply reconnect via SSH.
Affects only commands that are run with a specific interpreter specified.

When running commands, explicitly specify the path to the PHP interpreter of the desired version:

/usr/local/php52/bin/php
/usr/local/php53/bin/php
/usr/local/php54/bin/php
/usr/local/php55/bin/php
/usr/local/php56/bin/php
/usr/local/php70/bin/php
/usr/local/php71/bin/php
/usr/local/php72/bin/php
/usr/local/php73/bin/php
/usr/local/php74/bin/php
/usr/local/php80/bin/php
/usr/local/php81/bin/php
/usr/local/php82/bin/php
/usr/local/php83/bin/php
/usr/local/php84/bin/php
/usr/local/php85/bin/php

Either use shortened links like /usr/bin/php8.5 or just php8.5 (instead of 8.5 specify the desired version).

Attention!

To work with Composer, use version changing via the control panel or PATH. Aliases are also not suitable for use in PHP scripts, Bash scripts, cron and Supervisor — in these cases, you must specify the absolute path to the interpreter of the required PHP version.
  1. Open the "Hosting account settings" section (or "Hosting → Hosting account settings").
  2. In the "Aliases" section, specify php in the "Alias" field, specify /usr/local/php85/bin/php in the "Command" field (replace php85 with the version you need), and click "Change":
  3. Run the command source ~/.bashrc or . ~/.bashrc or simply reconnect via SSH.
Only affects the current SSH connection. To make the version apply to new connections, use the version changing via the control panel.

Redefine the PATH variable with the command (instead of php85, specify the desired version):

export PATH=/usr/local/php85/bin:$PATH
Tabla de conținut

    (3)