简体   繁体   English

两个版本的PHP-Mountain Lion

[英]Two versions of PHP - Mountain Lion

I have somehow got 2 versions of php installed on my machine (Mac OSx 10.8.3 Mountain Lion). 我已经在机器上安装了2个版本的php(Mac OSx 10.8.3 Mountain Lion)。 The locations of the 2 versions are - 这两个版本的位置是-

  1. /opt/local/bin (version 5.3.26) / opt / local / bin(版本5.3.26)
  2. /usr/bin (version 5.3.14) / usr / bin(版本5.3.14)

Right now, 'php -v' in the terminal returns, 5.3.26 but a simple php test page with the following code 现在,终端中的“ php -v”返回5.3.26,但是一个简单的php测试页包含以下代码

phpinfo();

return 5.3.15. 返回5.3.15。

Because of this mix-up i cant get php to load the mongodb extension. 由于这种混淆,我无法获得PHP来加载mongodb扩展名。 I'd want to work with version 5.3.26. 我想使用5.3.26版。

How do i get Apache to load this version of php ? 我如何让Apache加载此版本的php?

Your Apache is including libphp5.so of the wrong/the other installation. 您的Apache包含错误/ 其他安装的libphp5.so。

Option 1: 选项1:

See if you can find a libphp5.so file for your other PHP installation and point the Apache config to it (just put the whole path in the LoadModule line and restart Apache). 看看是否可以为其他 PHP安装找到libphp5.so文件,然后将Apache配置指向该文件(只需将整个路径放在LoadModule行中,然后重新启动Apache)。 If you cannot find such a file, the Apache module wasn't compiled for that PHP version. 如果找不到这样的文件,则说明该Apache版本未针对该PHP版本进行编译。 Compiling that may be a bit complicated, so in that case: 编译可能会有些复杂,因此在这种情况下:

Option 2: 选项2:

Figure out which PHP you're executing on the command line using which php and then just use the other one using the full path, eg instead of $ php ... use $ /usr/bin/php ... . 找出要在命令行上使用which php执行的which php ,然后使用完整路径使用另一个 $ php ... ,例如,代替$ php ...使用$ /usr/bin/php ... Note that you may still have different PHP configuration files for Apache and the CLI. 请注意,对于Apache和CLI,您可能仍然具有不同的PHP配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM