终端显示错误的 php 版本(雪豹)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3973271/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Terminal displays wrong php version (Snow Leopard)
提问by HArcher
Need to downgrade php to 5.2.x, so I followed this tutorial: http://andreys.info/blog/2010-03-25/compile-php-5-2-on-osx-10-6-snow-leopard#comment-631
需要将php降级到5.2.x,所以我跟着这个教程:http: //andreys.info/blog/2010-03-25/compile-php-5-2-on-osx-10-6-snow-leopard #comment-631
I'm on snow leopard 10.6.4, with xcode installed.
我在安装了 xcode 的雪豹 10.6.4 上。
So I compiled php5.2.x and completed the tutorial. phpinfo() loaded within the browser at htp://localhost says 5.2.x, Great!! But, Terminal command "php --version" says 5.3.x ??
于是我编译了php5.2.x,完成了教程。在 htp://localhost 的浏览器中加载的 phpinfo() 说 5.2.x,太棒了!!但是,终端命令“php --version”说 5.3.x ??
While compiling/installing php5.2.x, the new module file replaced the php5.3.x module here: /usr/libexec/apache2/libphp5.so
在编译/安装 php5.2.x 时,新的模块文件替换了此处的 php5.3.x 模块:/usr/libexec/apache2/libphp5.so
- So where is Terminal getting 5.3.x from?
- Do I have two php versions being loaded?
- Should I even care?
- 那么终端从哪里获得 5.3.x 呢?
- 我是否加载了两个 php 版本?
- 我应该关心吗?
回答by Parampal Pooni
For a more direct solution to the problem:
要更直接地解决问题:
Rename the OLD version of PHP
sudo mv /usr/bin/php /usr/bin/php5424
Create a Symbolic link for your new version of php so it can live in /usr/bin
sudo ln -s /usr/local/php5/bin/php /usr/bin/php
重命名旧版本的 PHP
sudo mv /usr/bin/php /usr/bin/php5424
为新版本的 php 创建一个符号链接,以便它可以位于 /usr/bin 中
sudo ln -s /usr/local/php5/bin/php /usr/bin/php
回答by johannes
- Check using
which php
. This should tell you which is being used. - Yes, looks like you have two installed at different locations.
- Yes, mind what's being used where. Having multiple versions is absolutely valid (at least on a development or testing system) but you always should be aware of the versions being used.
- 检查使用
which php
. 这应该告诉您正在使用哪个。 - 是的,看起来您在不同的位置安装了两个。
- 是的,介意在什么地方使用什么。拥有多个版本是绝对有效的(至少在开发或测试系统上),但您应该始终了解所使用的版本。