Home » Php » macos – Switch between PHP versions on OS X Mountain Lion

macos – Switch between PHP versions on OS X Mountain Lion

Posted by: admin July 12, 2020 Leave a comment

Questions:

Is it possible to have multiple versions of PHP installed on OS X Mountain Lion and freely change between them? Similar to the way MAMP allows you to. I’m wanting to get out of using MAMP and this is really the only feature holding me back.

How to&Answers:

Here’s a great blog post about Maintaining two versions of PHP with MacPorts. Should be sufficient enough for your needs.

Answer:

Even if I may get downvotes for this answer, I think I have to post it for the benefit of the OP.

Surely there is a way to achieve what you want, but you will loose a lot of time.

I often develop web applications on my OSX box and guess what… I use a Debian virtual machine to test them on a Webserver. It’s easier, faster, neater. I don’t need MacPorts to install even four different versions of PHP, I can test all the pecl extensions compiling them with a simple command. I can simulate any possible Linux server environment with just a few commands in the virtual machine console, without hacking the sources to make them work under OSX, and without screwing anything up.

Answer:

For anyone wanting to do it with Homebrew:
After successfully installing different versions of php (or any program versions) on can switch between them from the command line:

brew unlink php53 && brew link php54

Some more tips here:
https://github.com/mxcl/homebrew/wiki/Tips-N%27-Tricks