2.8.7. Change PHP version for console

Attention!

Changing PHP version to PHP settings site does not affect PHP version in console.

The command to view the current PHP version:

php -v
  1. Open the section "HostingLinux configuration".
  2. In the block "PHP version" select the version you want and click "Save":
  3. Execute the command source ~/.bashrc or . ~/.bashrc, or just reconnect via SSH.

The installed version will be valid for all new SSH connections.

When executing commands, explicitly specify the path to the PHP interpreter of the required version:

/usr/local/php4/bin/php
/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

Or use shortened links like /usr/bin/php8.2 or simply php8.2 (insteadof 8.2 specify the correct version).

Attention!

To work with Composer use the version change method via control panel or overriding PATH. Also aliases are not suitable for use in PHP scripts, Bash scripts and cron — in them, be sure to indicate the full the absolute path to the PHP interpreter the version you want.
  1. Open the section "HostingLinux configuration".
  2. In the block "Aliases" in the first field specify php, in the second — the command /usr/local/php82/bin/php (insteadof php82 specify the desired version) and click "Save":
  3. Execute the command source ~/.bashrc or . ~/.bashrc, or just reconnect via SSH.

Override the variable PATHby running the command (in the command, replace php82 to the required PHP version):

export PATH=/usr/local/php82/bin:$PATH

The installed version will only work for the current SSH connection. To make the version work for new connections, use the change version method via control panel.

Content