Traveling Tech Guy
Traveling Tech Guy

Reputation: 27811

Switching PHP version with MacPort

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?

Upvotes: 4

Views: 7243

Answers (2)

Marco M. von Hagen
Marco M. von Hagen

Reputation: 219

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.

Upvotes: 12

Traveling Tech Guy
Traveling Tech Guy

Reputation: 27811

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.

Upvotes: -2

Related Questions