Note de ce sujet :
  • Moyenne : 4 (1 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5
Switch php versions on command line alternative
#1
[titreyoyo]Installing Multiple Alternative Versions of PHP[/titreyoyo]

Let’s give it a try

First things first, check out which version of PHP is being used on your local computer at that particular moment.

Code :
$ php -v
PHP 7.4.24 (cli) (built: Sep 23 2021 21:35:51) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.24, Copyright (c), by Zend Technologies
Then, just take a look at which PHP versions you’ve got currently installed.

Code :
$ update-alternatives --list php
/usr/bin/php7.2
/usr/bin/php7.4
Here is how to switch among different versions of PHP.


Code :
$ sudo update-alternatives --config php
There are 2 choices for the alternative php (providing /usr/bin/php).
Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php7.4   74        auto mode
  1            /usr/bin/php7.2   72        manual mode
  2            /usr/bin/php7.4   74        manual mode
Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/php7.2 to provide /usr/bin/php (php) in manual mode
After selecting number 1 in this particular example, you’d expect to obtain the following output if inspecting the PHP version, once again.

Code :
$ php -v
PHP 7.2.34-24+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Aug 26 2021 15:55:24) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.34-24+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Source de l'information : https://medium.com/geekculture/installin...acc7af3260
Répondre


Messages dans ce sujet
Switch php versions on command line alternative - par yoyo - 07-11-2022, 21:46

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)