简体   繁体   English

在 OS X Mountain Lion 上的 PHP 版本之间切换

[英]Switch between PHP versions on OS X Mountain Lion

Is it possible to have multiple versions of PHP installed on OS X Mountain Lion and freely change between them?是否可以在 OS X Mountain Lion 上安装多个版本的 PHP 并在它们之间自由更改? Similar to the way MAMP allows you to.类似于 MAMP 允许您这样做的方式。 I'm wanting to get out of using MAMP and this is really the only feature holding me back.我想停止使用 MAMP,这确实是唯一阻碍我的功能。

Even if I may get downvotes for this answer, I think I have to post it for the benefit of the OP.即使我可能对这个答案投反对票,我想我也必须为了 OP 的利益而发布它。

Surely there is a way to achieve what you want, but you will lose 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.我经常在我的 OSX 机器上开发 Web 应用程序并猜猜是什么......我使用Debian 虚拟机在 Web 服务器上测试它们。 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.我什至不需要 MacPorts 来安装四个不同版本的 PHP,我可以测试所有pecl扩展,用一个简单的命令编译它们。 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.我可以在虚拟机控制台中只用几条命令来模拟任何可能的 Linux 服务器环境,而无需破解源代码以使其在 OSX 下工作,也不会搞砸任何事情。

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:对于任何想要使用 Homebrew 进行操作的人:成功安装不同版本的 php(或任何程序版本)后,可以从命令行在它们之间切换:

brew unlink php53 && brew link php54

Some more tips here: https://github.com/mxcl/homebrew/wiki/Tips-N%27-Tricks这里还有一些提示: https : //github.com/mxcl/homebrew/wiki/Tips-N%27-Tricks

Here's a great blog post about Maintaining two versions of PHP with MacPorts .这是一篇关于使用 MacPorts 维护 PHP 的两个版本的精彩博客文章。 Should be sufficient enough for your needs.应该足以满足您的需求。

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

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