doudun1934 2016-06-22 09:26
浏览 27

如何在Mac OSX El Capitan中更改PHP版本?

I'm using a MAMP setup in Mac OS 10.11.5 (El Capitan). This works fine for web server purposes, but when I try to use the PHP CLI, Terminal uses the system version:

$ which php

From everything I've found and read, it seems like the solution is to add the MAMP version to my PATH:


However, after adding this, closing and re-opening the window, and sourcing the file, Terminal still doesn't find the version I want.

  • 写回答

1条回答 默认 最新

  • doutuo3935 2016-06-22 09:43

    There is a gist for this

    Within the Terminal, run vim ~/.bash_profile
    Type i and then paste the following at the top of the file:
    export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
    Hit ESC, Type :wq, and hit Enter
    In Terminal, run source ~/.bash_profile
    In Terminal, type in which php again and look for the updated string. If everything was successful, It should output the new path to MAMP PHP install.
    In case it doesn't output the correct path, try closing the terminal window (exit fully) and open again, it should apply the changes (Restart in short).
    本回答被题主选为最佳回答 , 对您是否有帮助呢?



    • ¥15 spyder运行重复
    • ¥15 有偿做一个PUBG识别枪械配合罗技宏的
    • ¥15 我考考你,这代码是对的还是错的?
    • ¥15 我用C语言easyx图形库绘制了一个3d游戏方框透视,但进入游戏时候鼠标准星对准方框边缘 鼠标光标就会弹出来这是啥情况怎样让光标对准绘制的方框点击鼠标不弹出光标好烦这样
    • ¥20 用Power Query整合的问题
    • ¥20 基于python进行多背包问题的多值编码
    • ¥15 相同型号电脑与配置,发现主板有一台貌似缺少了好多元器件似的,会影响稳定性和使用寿命吗?
    • ¥15 C语言:数据子序列基础版
    • ¥20 powerbulider 导入excel文件,显示不完整
    • ¥15 paddle训练自己的数据loss降不下去