简体   繁体   English

mac用homebrew升级本机php,而不是让它工作

[英]mac upgrading native php with homebrew, not getting it to work

I tried to update the native php of my mba from 5.3.X to 5.4.XI did this: brew tap homebrew/dupes brew tap josegonzalez/homebrew-php brew update brew install php54 我试图将我的mba的原生php从5.3.X更新到5.4.XI这样做:brew tap homebrew / dupes brew tap josegonzalez / homebrew-php brew update brew install php54

This installs php 5.4 on /usr/local/cellar/php54 now when doing which php, it gives me /usr/bin/php 这样在/ usr / local / cellar / php54上安装php 5.4时做了哪个php,它给了我/ usr / bin / php

I tried to add this to ~/.bashrc : export PATH=/usr/local/cellar/php54:$PATH 我试着将它添加到〜/ .bashrc:export PATH = / usr / local / cellar / php54:$ PATH

Now when i re-open terminal and type which php it still tells me php is located in /usr/bin/php 现在当我重新打开终端并输入哪个php时它仍然告诉我php位于/ usr / bin / php

Is there a good way to fix this issue? 有没有一种解决这个问题的好方法?

From https://github.com/josegonzalez/homebrew-php 来自https://github.com/josegonzalez/homebrew-php

If you would like to swap the PHP you use on the command line, you should update the $PATH variable in either your .bashrc or .bash_profile: 如果您想在命令行中交换使用的PHP,则应更新.bashrc或.bash_profile中的$ PATH变量:

 # Swapping from PHP53 to PHP54 # export PATH="$(brew --prefix josegonzalez/php/php53)/bin:$PATH" export PATH="$(brew --prefix josegonzalez/php/php54)/bin:$PATH" 

Please be aware that you must make this type of change EACH time you swap between PHP minor versions. 请注意,您必须在PHP次要版本之间进行此类更改。 You will typically only need to update the Apache/FPM when upgrading your php patch version. 升级php补丁版本时,通常只需要更新Apache / FPM。

通常路径没有正确导出,因此不仅php而且许多其他brew安装可能无法正常工作,请尝试以下方法:

echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM