0

I tried to change my PHP CLI version with sudo update-alternatives --config php:

There are 2 choices for the alternative php (providing /usr/bin/php).

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/php8.1      81        auto mode
* 1            /usr/bin/php8.0.15   1         manual mode
  2            /usr/bin/php8.1      81        manual mode

I set it to 0 and checked it with update-alternatives --display php:

php - auto mode
  link best version is /usr/bin/php8.1
  link currently points to /usr/bin/php8.1
  link php is /usr/bin/php
  slave php.1.gz is /usr/share/man/man1/php.1.gz
/usr/bin/php8.0.15 - priority 1
/usr/bin/php8.1 - priority 81
  slave php.1.gz: /usr/share/man/man1/php8.1.1.gz

It looks like it worked, but if I check it with php -v then I get:

PHP 8.0.15 (cli) (built: Jun  7 2022 10:21:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.15, Copyright (c) Zend Technologies

command -v php outputs /usr/local/bin/php.


I'm using Ubuntu 22.04 LTS

0

1 Answer 1

2

You presumably have /usr/local/bin ahead of /usr/bin in your PATH, and since there’s a php binary in /usr/local/bin, your shell uses that. The php alternative configured by update-alternatives ends up having no effect — at least, on anything based on that PATH.

To fix this, in your case, I recommend removing the PHP installation in /usr/local. A simpler approach would be to re-order your PATH, but that might affect other binaries you rely on in /usr/local/bin.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .