Laravel Homestead:切换 PHP 版本(PHP 命令行)
Homestead 中使用此命令:
$ sudo update-alternatives --config php
会弹出选项:
$ sudo update-alternatives --config php
There are 7 choices for the alternative php (providing /usr/bin/php).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/php8.0 80 auto mode
1 /usr/bin/php5.6 56 manual mode
2 /usr/bin/php7.0 70 manual mode
3 /usr/bin/php7.1 71 manual mode
4 /usr/bin/php7.2 72 manual mode
5 /usr/bin/php7.3 73 manual mode
* 6 /usr/bin/php7.4 74 manual mode
7 /usr/bin/php8.0 80 manual mode
Press <enter> to keep the current choice[*], or type selection number:
填入数字:
$ sudo update-alternatives --config php
There are 7 choices for the alternative php (providing /usr/bin/php).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/php8.0 80 auto mode
1 /usr/bin/php5.6 56 manual mode
2 /usr/bin/php7.0 70 manual mode
3 /usr/bin/php7.1 71 manual mode
4 /usr/bin/php7.2 72 manual mode
5 /usr/bin/php7.3 73 manual mode
* 6 /usr/bin/php7.4 74 manual mode
7 /usr/bin/php8.0 80 manual mode
Press <enter> to keep the current choice[*], or type selection number: 7
update-alternatives: using /usr/bin/php8.0 to provide /usr/bin/php (php) in manual mode
命令行确认一下:
$ php -v
PHP 8.0.1 (cli) (built: Jan 13 2021 08:22:35) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.1, Copyright (c) Zend Technologies
with Zend OPcache v8.0.1, Copyright (c), by Zend Technologies