MacOS安装valet遇到unable to determine linked PHP

我们进行Laravel项目开发时,可以选择多种运行环境,可以选择轻量级的PHP服务器,homestead虚拟机,也可以选择Valet,如果你时纯新手或者配置开发环境和运行环境总失败的话,你也可以选择我打包好的Deepin OS开发环境,里面所有咱们需要的环境和软件我都安装好了(开箱即用的Laravel开发环境)。无论哪种开发环境,建议大家都学着自己配置一下,遇到问题也不要害怕,这其实也是咱们技能积累的一个过程,我们这篇文章就是帮大家解决一下安装和配置Valet服务器环境时遇到的一个问题。

这个问题发生在运行 valet install 的时候,安装过程中弹出Unable to determine linked PHP 这个错误:

 

artisans-Mac:~ artisan$ valet install

 

No log handling enabled - using stderr logging

Created directory: /var/db/net-snmp

Created directory: /var/db/net-snmp/mib_indexes

Stopping nginx...

Installing nginx...

[nginx] is not installed, installing it now via Brew... ?

Installing nginx configuration...

Installing nginx directory...

Installing php71...

Error: homebrew/dupes was deprecated. This tap is now empty as all its formulae were migrated.

Error: homebrew/versions was deprecated. This tap is now empty as all its formulae were migrated.

Updating Homebrew...

Error: homebrew/php was deprecated. This tap is now empty as all its formulae were migrated.

[php71] is not installed, installing it now via Brew... ?

Updating PHP configuration...


In Brew.php line 182:

Unable to determine linked PHP.

install

  

很多人不知道如何解决这个问题,在网络上搜索也很难找到这个问题的答案,但其实这个错误提示本身就告诉了我们解决办法,只要咱们做好连接就行了,之所以发生这个问题,是因为homebrew不确定连接哪个版本的PHP,虽然咱们安装valet的时候它自动帮我们安装了PHP 7.1,但是这个时候Mac系统里却存在两个版本的PHP,它不知道要与哪个版本进行交互连接了。要解决这个问题,咱们只需要运行下面这个命令就可以了:

brew link php71 --force
artisans-Mac:~ artisan$ php -v

PHP 7.1.16 (cli) (built: Apr 1 2018 13:14:42) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

artisans-Mac:~ artisan$ brew link php71 --force

Linking /usr/local/Cellar/php@7.1/7.1.19... 25 symlinks created

If you need to have this software first in your PATH instead consider running:

echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profile

 

通过上面的执行结果大家就会发现,当前php的版本是 PHP 7.1.16,我们强制关联之后关联的是最新的 PHP 7.1.19,我们再次运行

valet install

 

Password:

Stopping nginx...

Installing nginx configuration...

Installing nginx directory...

Updating PHP configuration...

Restarting php@7.1...

Installing dnsmasq...

[dnsmasq] is not installed, installing it now via Brew... ?

Restarting dnsmasq...

Restarting nginx...


Valet installed successfully!

 

这个时候就不会弹出之前的错误了,这个问题呢,咱们也就完美的解决了,其实10.12版本是没有这个问题的,好像MacOS新版系统才出现了这个问题,AnyWay,管他呢,反正咱们解决了就行了。

 

最后呢,欢迎各位常来做客,希望这篇豆腐能帮到遇到这个问题的朋友们。