如何使用MAMP的PHP版本而不是OSX的默认版本 [英] How to use MAMP's version of PHP instead of the default on OSX

查看:125
本文介绍了如何使用MAMP的PHP版本而不是OSX的默认版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用MAMP的PHP版本,而不是Mac上安装的默认版本.我尝试使用

I would like to use MAMP's version of PHP instead of the default installed on my mac. I tried using

ln -s /Applications/MAMP/bin/php5.3/bin/php php

但是出现文件存在"错误.解决此问题的最佳方法是什么,所以我可以只键入php而不是完整路径?

but I get a "File exists" error. What's the best way to work around this so I can just type php instead of the full path?

推荐答案

我不建议您尝试修改在命令行上调用的PHP的默认版本.如果您决定升级操作系统,这样做可能会破坏系统的其他部分,并在将来给您带来问题.

I would not recommend trying to modify the default version of PHP that is called on the command line. Doing so may break other parts of your system as well as provide you with problems in the future, should you decide to upgrade your OS.

有一种替代方案可以满足您的需求.您可以为MAMP的php 5.3副本创建别名.在我的情况下,我将别名命名为phpmamp.打开终端并输入:

There is an alternative that may meet your needs. You can create an alias to your copy of MAMP's php 5.3. In my case I named the alias phpmamp. Open your terminal and type:

alias phpmamp='/Applications/MAMP/bin/php5.3/bin/php'

现在,在命令行中输入phpmamp将启动MAMP php interperter.通过键入以下内容进行验证:

Now, typing phpmamp at the command line will launch the MAMP php interperter. Verify this by typing:

phpmamp --help

您很可能希望将其以及任何其他别名存储在~/.bash_profile中,这将使别名在重新引导后得以持久.否则,别名仅应持续于您所在的特定终端会话.有关创建.bash_profile文件的更多信息,请参见:

You will most likely want to store this, and any other alias, in a ~/.bash_profile This will allow the aliases to persist across reboots. Otherwise, the alias should only last for the particular terminal session you are in. More information about creating a .bash_profile file can be found here:

http://www.redfinsolutions.com/redfin-blog/正在创建bashprofile-您的Mac

这篇关于如何使用MAMP的PHP版本而不是OSX的默认版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆