douyi3833
2014-07-08 19:11
浏览 207
已采纳

使用MacPort切换PHP版本

I've installed PHP 5.4 with MacPorts, using all the ports I had on my current PHP 5.3. I then (foolishly) ran the command sudo port select --set php php54 and received Selecting 'php54' for 'php' succeeded. 'php54' is now active.

However, I couldn't run any of my current PHP pages, receiving a 'Forbidden' error from Apache. I decided to switch back to 5.3, and ran sudo port select --set php php5 only to receive Selecting 'php5' for 'php' failed: The specified version 'php5' is not valid.. I tried the same with php53 - and got the same message.

To verify what's installed I ran port installed php* and got:

php5 @5.3.28_0+apache2+pear (active) php5-apc @3.1.9_1 (active) php5-curl @5.3.28_0 (active) php5-iconv @5.3.28_0 (active) php5-mbstring @5.3.28_0 (active) php5-mcrypt @5.3.28_0 (active) php5-memcache @2.2.7_0 (active) php5-mysql @5.3.28_0+mysqlnd (active) php5-openssl @5.3.28_0 (active) php5-xdebug @2.2.5_0 (active) php54 @5.4.30_0+libedit (active) php54-apache2handler @5.4.30_0 (active) php54-APC @3.1.13_0 (active) php54-curl @5.4.30_0 (active) php54-iconv @5.4.30_0 (active) php54-mbstring @5.4.30_0 (active) php54-mcrypt @5.4.30_0 (active) php54-memcache @2.2.7_0 (active) php54-mysql @5.4.30_0+mysqlnd (active) php54-openssl @5.4.30_0 (active) php54-xdebug @2.2.5_0 (active) php_select @1.0_0 (active)

So, there are 2 version of PHP installed. How do I switch back to PHP 5.3? And why is running 5.4 encounters a permissions issue?

图片转代码服务由CSDN问答提供 功能建议

我使用MacPorts安装了PHP 5.4,使用了当前PHP 5.3上的所有端口。 I然后 (愚蠢地)运行命令 sudo port select --set php php54 并收到为'php'选择'php54'成功。 'php54'现在处于活动状态。

但是,我无法运行任何当前的PHP页面,从Apache收到“Forbidden”错误。 我决定切换回5.3,然后运行 sudo port select --set php php5 只接收为'php'选择'php5'失败:指定版本'php5'无效 。 我尝试了同样的php53 - 并得到了相同的消息。

要验证安装了什么我运行了 port安装了php * 并得到了:

php5 @ 5.3.28_0 + apache2 + pear(active) php5-apc @ 3.1.9_1(active) php5-curl @ 5.3.28_0(active) php5- iconv @ 5.3.28_0(主动) php5-mbstring @ 5.3.28_0(主动) php5-mcrypt @ 5.3.28_0(主动) php5-memcache @ 2.2.7_0(主动) php5-mysql @ 5.3.28_0 + mysqlnd(主动) php5-openssl @ 5.3.28_0(主动) php5-xdebug @ 2.2.5_0(主动) php54 @ 5.4.30_0 + libedit(主动) php54-apache2handler @ 5.4.30_0(主动) php54-APC @ 3.1.13_0(主动) php54-curl @ 5.4.30_0(主动) php54-iconv @ 5.4.30_0(主动) php54-mbstring @ 5.4。 30_0(活动) php54-mcrypt @ 5.4.30_0(活动) php54-memcache @ 2.2.7_0(活动) php54-mysql @ 5.4.30_0 + mysqlnd(活动) php54-openssl @ 5.4。 30_0(活动) php54-xdebug @ 2.2.5_0(活动) php_select @ 1.0_0(活动)

因此,有2个版本的PHP 安装。 如何切换回PHP 5.3? 为什么运行5.4会遇到权限问题?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douba1214 2014-07-12 19:40
    已采纳

    Well, I haven't been able to revert to 5.3. I ended up fixing the access rights error, and I'm currently using 5.4. Fortunately, it's backwards compatible (at least, I have not hit on anything significant yet).

    Bottom line - be careful with Ports activations - there may be no (known) going back.

    已采纳该答案
    打赏 评论
  • douyun3799 2015-06-24 00:16

    Maybe it's a good idea to ask port which post are available by invoking:

    sudo port select --list php
    

    Then you get a list of all the php versions port knows about

    You can only do

    sudo port select --set php <onOfTheList>  
    

    In my case, it was a python port, and port select --list python gave me a python26-apple. To get back to this known port, I had to enter

    sudo port select --set python python27-apple
    

    and this made the reverse.

    打赏 评论

相关推荐 更多相似问题