Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Composer PHP Version Path Plesk

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
like image 210
Mathieu Mourareau Avatar asked Jan 30 '23 00:01

Mathieu Mourareau


1 Answers

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...

like image 91
Webconstructor Avatar answered Feb 03 '23 07:02

Webconstructor