Default PHP-CLI version for Zone managed servers (shared hosting, smart dedicated servers) have the same PHP version as the main host does.
You can check the current version used like this:
php -v
This gives the following answer:
virt1234:sn-69-1.tll07.zoneas.eu:~> php -v PHP 8.1.13 (cli) (built: Nov 28 2022 08:06:02) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.13, Copyright (c) Zend Technologies with Zend OPcache v8.1.13, Copyright (c), by Zend Technologies
Changing the version
You can change the shared hosting PHP version via admin panel under Web Server settings. This will change the main PHP version and also CLI version.
For changing the only PHP CLI version you need to create symlink to desired PHP version’s file in a ~/bin/ folder.
Depending on the server platform, run one of the two commands for the required version of PHP CLI.
Example for PHP 8.1:
> mkdir -p ~/bin && ln -sf /usr/bin/php81-cli ~/bin/php
Example for PHP 7.4:
> mkdir -p ~/bin && ln -sf /usr/bin/php74-cli ~/bin/php
Example for PHP 7.3:
mkdir -p ~/bin && ln -sf /usr/bin/php73-cli ~/bin/php
After running this command, re-login to SSH and after that php -v
shows version 7.3.
If you need to run PHP 5.6 or 7.2 then you must create symlink to php56-cli or php72-cli.
NB! After creating this link, PHP CLI version will not change automatically in the future.
To remove the excising symlink run this command:
rm -f ~/bin/php