magento - composer update on cpanel terminal wrong php version - Stack Overflow

admin2025-04-19  0

In cpanel i changed php version from MultiPHP Manager of my domain to 8.1 but when i connect terminal and try to upgrade magento version giving me error of old php version

Problem 1
    - Root composer.json requires magento/product-community-edition 2.4.7-p4 -> satisfiable by magento/product-community-edition[2.4.7-p4].
    - magento/product-community-edition 2.4.7-p4 requires php ~8.1.0||~8.2.0||~8.3.0 -> your php version (7.4.33) does not satisfy that requirement.

when i cd to domain and run php -v it says 8.1 but when i go back to root directory and php -v it says 7.4

i tried /usr/local/bin/ea-php81 /opt/cpanel/composer/bin/composer update and still takin old php version

In cpanel i changed php version from MultiPHP Manager of my domain to 8.1 but when i connect terminal and try to upgrade magento version giving me error of old php version

Problem 1
    - Root composer.json requires magento/product-community-edition 2.4.7-p4 -> satisfiable by magento/product-community-edition[2.4.7-p4].
    - magento/product-community-edition 2.4.7-p4 requires php ~8.1.0||~8.2.0||~8.3.0 -> your php version (7.4.33) does not satisfy that requirement.

when i cd to domain and run php -v it says 8.1 but when i go back to root directory and php -v it says 7.4

i tried /usr/local/bin/ea-php81 /opt/cpanel/composer/bin/composer update and still takin old php version

Share edited Mar 4 at 7:45 Kareem k asked Mar 4 at 7:22 Kareem kKareem k 1244 bronze badges 1
  • Please keep in mind that you should never run composer update on your production system! – Nico Haase Commented Mar 4 at 13:14
Add a comment  | 

1 Answer 1

Reset to default 0

I assume this is a rented hosting service. You have access to your hosting. In the root directory, you should find a .bashrc file, which allows you to override the default aliases for yourself. (If there is no .bashrc, create one.)

Add the appropriate aliases for both PHP and Composer to this .bashrc file, like this:

alias php='/usr/local/bin/ea-php81'
alias composer='php /opt/cpanel/composer/bin/composer'

Now php -v always will get 8.1 result instead of 7.4. You will now access your Composer through the new alias php. You should know the exact path, but these are the ones I usually recommend for cPanel. I assume it should be similar.

The default PHP alias considers the version used by the server's cPanel as the main version (currently 7.4), so it can only be updated by the server administrators. However, with the .bashrc, you have the option to override this (to 8.1 or another version) for yourself by setting a new alias.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745057591a282496.html

最新回复(0)