4

RESOLVED :

For plesk users you need to make nano .bash_profile when you are in the file add this line :

PATH=/opt/plesk/php/7.1/bin:$PATH 

it will work for ssh users !!

for root ssh user you can do :

export PATH=/opt/plesk/php/7.1/bin:$PATH;

Hope it will help

I try to say to composer that now he needs to look on the php version 7.1 wish is installed on my plesk serveur.

how i could do this ? i am not a pro in commands line.. i think i need to add this line

export PATH=/opt/plesk/php/7.1/bin:$PATH; in my .bashrc file but i really don't know how to access to this and how to add the line.

hope someone could help me for this, thanks a lot in advance.

Actually i need to do manualy this to update composer :

export PATH=/opt/plesk/php/7.1/bin:$PATH; php composer.phar update
Mathieu Mourareau
  • 1,140
  • 2
  • 23
  • 47
  • Yes if you want to use a different php version you will have to first select it. Like this `/opt/plesk/php/7.1/bin/php composer.phar`. If you type `php -v` it will give you the default php version of the server - and to change that you will have to contact your hosting provider (without being completely sure) – Antonios Tsimourtos Jul 13 '17 at 07:59
  • thanks for your answer ! when i do php -v i get php version 5.6.30 how could i change it ? because my provider don't know really. i have multiple php version installed but by default my plesk serveur use php 5.6.30 – Mathieu Mourareau Jul 13 '17 at 08:08
  • could i just simply say to composer to use the new php path ? in .bashrc ! only problem , i don't know how to do this – Mathieu Mourareau Jul 13 '17 at 08:10
  • I don't know i have the same "problem". Until now i use "/opt/plesk/php/7.1/bin/php command_here" . I think the only way is to say to your hosting provider to change your default php version to 7.1 – Antonios Tsimourtos Jul 13 '17 at 08:10
  • 1
    Check [this](https://stackoverflow.com/a/31839067/6140684) (but check the question too in order to understand) – Antonios Tsimourtos Jul 13 '17 at 08:15
  • i will check now !!! it's seems to be the topic what i looked for :) – Mathieu Mourareau Jul 13 '17 at 09:25

2 Answers2

5

I had the same problem with both Composer and WP CLI in a Plesk Onyx environment

Problem 1 - This package requires php ^7.2 but your PHP version (5.4.16) does not satisfy that requirement.

And something similar when trying to run WP CLI

php -v

PHP 7.2.23 (cli) (built: Sep 27 2019 11:40:34) ( NTS )

Solved it with a symlink like so,

after loggin in on the right domain with ssh:

cd /usr/bin
mv php php_OLD
ln -s /opt/plesk/php/7.2/bin/php php

and after testing cleaning up:

rm php_OLD

I discoverd only very slowly that the php binary which both applications use is in /usr/bin

So what the code does is:

  • go to that directory
  • rename php for backup purpose
  • create a symlink to the correct path of the right plesk php binary

worked instantly

hope this helps someone to solve this puzzle quicker than I did...

Webconstructor
  • 525
  • 2
  • 6
  • 15
4

A slightly alternative version if it may help anyone:

Create an alias for composer and store it in /etc/profile.d (so it is available to all users)

cd /etc/profile.d
nano composer7.sh

In your file put this (adjusting for version & composer location):

alias composer7='/opt/plesk/php/7.0/bin/php /usr/local/bin/composer.phar'

Save the file and login again.

Your script can now be used from command line even if your installation of Plesk is running a different version of php. Now you can execute it like:

composer7 update
taekwondoalex
  • 386
  • 4
  • 12