我已经在我的 PC 上安装了 PHP7.2,但是当我尝试安装时,php -v
它显示了这样的错误
bash: /usr/local/bin/php: No such file or directory
然后我尝试输入php7.2 -v
它的作品
有人有解决方案,所以当我输入 php -v 时它会显示 php7.2?
答案1
只需安装 php 替代包(https://packages.ubuntu.com/bionic/php)
sudo apt install php
你将获得新的符号链接
~$ ll /usr/bin/php7.2
-rwxr-xr-x 1 root root 4.7M Apr 18 16:12 /usr/bin/php7.2*
~$ ll /usr/bin/php
lrwxrwxrwx 1 root root 21 Mar 7 17:05 /usr/bin/php -> /etc/alternatives/php*
~$ ll /etc/alternatives/php
lrwxrwxrwx 1 root root 15 Mar 7 17:05 /etc/alternatives/php -> /usr/bin/php7.2*
~$ php -v
PHP 7.2.17-0ubuntu0.18.04.1 (cli) (built: Apr 18 2019 14:12:38) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.17-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
~$ php7.2 -v
PHP 7.2.17-0ubuntu0.18.04.1 (cli) (built: Apr 18 2019 14:12:38) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.17-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies