Home >Backend Development >PHP Tutorial >Using MAMP's PHP to replace the system's own PHP under OSX
The PHP replacement system using MAMP under OSX comes with PHP
Foreword
As we all know, OSX comes with itPHP
和Apache
, obviously these are not what we need.
Many people will install an integrated environment as their development environment. For example, I chose MAMP and the PHP version is 7.0.
Problem
I executed php -v
in the OSX terminal, and what appeared was the built-in PHP5.5php -v
,出现的是自带的PHP5.5
<code>yu@bogon ~ $ php -v PHP <span>5.5</span>.<span>31</span> (cli) (built: Feb <span>20</span><span>2016</span><span>20</span>:<span>33</span>:<span>10</span>) Copyright (c) <span>1997</span>-<span>2015</span> The PHP Group Zend Engine v2.<span>5.0</span>, Copyright (c) <span>1998</span>-<span>2015</span> Zend Technologies</code>
这样就会出现在运行一些框架的命令行工具,比如Yii、Laravel,会出现问题。
解决方案
删除自带php和apache
OSX之所以会自带apache和php环境,是因为一些系统工具会使用,如果删掉的话,可能导致某些工具不能使用。
不推荐这个方法。
添加到环境变量
<code><span>echo</span><span>$SHELL</span></code>
我们可以修改的配置文件有下面几种
经过测试,居然都没有生效。。。。
所以采用最后的方式。
alias 别名
由于我采用的是zsh,所修改的配置文件的位置是~/.zshrc
<code>alias php=<span>"/Applications/mamp/php/bin/php"</span></code>like this Problems will occur when running command line tools of some frameworks, such as Yii and Laravel. SolutionDelete the built-in php and apache
<code>yu@bogon ~ $ php -v PHP <span>7.0</span>.<span>0</span> (cli) (built: Dec <span>4</span><span>2015</span><span>01</span>:<span>16</span>:<span>36</span>) ( NTS ) Copyright (c) <span>1997</span>-<span>2015</span> The PHP Group Zend Engine v3.<span>0.0</span>, Copyright (c) <span>1998</span>-<span>2015</span> Zend Technologies with Zend OPcache v7.<span>0.6</span>-dev, Copyright (c) <span>1999</span>-<span>2015</span>, by Zend Technologies</code>
csh or tcsh, C Shell
After testing, it didn’t take effect. . . .
So adopt the last method.
🎜alias alias🎜🎜Since I am using zsh, the location of the modified configuration file is~/.zshrc
🎜🎜Add alias at the end of the configuration file to let the php command point directly to MAMP's php The reason why the path 🎜rrreee🎜 is adopted in this way is that it is safe and does not affect the convenience of calling system PHP by other software. Current users will directly call PHP7. If I delete MAMP, I can modify the alias directly to avoid changes. What an unexpected bug🎜🎜🎜Result🎜rrreee🎜References🎜🎜🎜http://stackoverflow.com/questions/4145667/how-to-override-the-path-of-php-to-use-the-mamp- path🎜🎜http://blog.sina.com.cn/s/blog_68431a3b0102vpny.html🎜🎜https://www.zhihu.com/question/20916296🎜🎜http://elf8848.iteye.com/blog/1582137 🎜🎜🎜').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i 🎜').text(i));
};
$numbering.fadeIn(1700);
});
});
🎜
🎜
The above introduces the use of MAMP under OSX to replace the system's own PHP, including the content. I hope it will be helpful to friends who are interested in PHP tutorials. 🎜
🎜
🎜