Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 904
Traveling Tech Guy Avatar asked Oct 12 '25 14:10

Traveling Tech Guy


1 Answers

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.

like image 114
Marco M. von Hagen Avatar answered Oct 14 '25 03:10

Marco M. von Hagen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!