Reputation: 5618
I need to switch Php version from 5.4 to 5.5. I adjusted Php version in Cpanel. Now current version seems 5.5 in Cpanel. However, I can't see a change when I execute this command from command pompt:
php -v
This is output of it:
PHP 5.4.45 (cli) ...
How can I switch Php version for Command line?
Upvotes: 3
Views: 6883
Reputation: 493
I solved it using this: /opt/cpanel/ea-php73/root/usr/bin/php /opt/cpanel/composer/bin/composer update
I'm using Cpanel & WHM v96.0.15
Upvotes: 3
Reputation: 1167
For those who have these problem with any PHP version, you can create a symbolic link to the php version you want and edit the PATH to prioritize your command per user:
> mkdir bin
> ln -s /usr/local/bin/ea-php73 bin/php
> vim .bashrc
#Put the following code on bottom
export PATH="/home/[usuario]/bin:$PATH"
Logout, login and try php -v
Upvotes: 4
Reputation: 4529
You can change the php version using EasyApache4 and MultiPHP (that would be one way to do it).
Another way would be to have CloudLinux license, install Cloudlinux kernel and CageFS + PHPSelector. This way each cPanel user can have its own custom php version no matter what php version runs on the server (You can change the php version from cPanel, from 5.x to 7.x). Of course, for isntalling composer you will need to provide ssh access to that user.
You can run EasyApache as root on a ssh console or via WHM. If you just have a cPanel account and not root access you won't be able to change the PHP version. Even if you change it you cant installer composer without ssh access.
Upvotes: 0
Reputation: 396
Yes, You can. cpanel
comes with a script called easyapache
. You can find the script under
/scripts/easyapache
. Its an interactive script will let you choose versions on the go.
Upvotes: 0