终端显示错误的 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 11:36:35  来源:igfitidea点击:

Terminal displays wrong php version (Snow Leopard)

phpmacosterminalosx-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

  1. So where is Terminal getting 5.3.x from?
  2. Do I have two php versions being loaded?
  3. Should I even care?
  1. 那么终端从哪里获得 5.3.x 呢?
  2. 我是否加载了两个 php 版本?
  3. 我应该关心吗?

回答by Parampal Pooni

For a more direct solution to the problem:

要更直接地解决问题:

  1. Rename the OLD version of PHP

    sudo mv /usr/bin/php /usr/bin/php5424

  2. 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

  1. 重命名旧版本的 PHP

    sudo mv /usr/bin/php /usr/bin/php5424

  2. 为新版本的 php 创建一个符号链接,以便它可以位于 /usr/bin 中

    sudo ln -s /usr/local/php5/bin/php /usr/bin/php

回答by johannes

  1. Check using which php. This should tell you which is being used.
  2. Yes, looks like you have two installed at different locations.
  3. 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.
  1. 检查使用which php. 这应该告诉您正在使用哪个。
  2. 是的,看起来您在不同的位置安装了两个。
  3. 是的,介意在什么地方使用什么。拥有多个版本是绝对有效的(至少在开发或测试系统上),但您应该始终了解所使用的版本。