且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用MAMP的PHP版本而不是OSX的默认版本

更新时间:2023-02-22 20:24:29

我不建议您尝试修改在命令行上调用的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