如何在 MAC OS X 10.7 Lion 上安装多个 XAMPP 版本或多个 PHP 版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12501003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:41:38  来源:igfitidea点击:

How to install multiple XAMPP versions OR Multiple PHP versions on MAC OS X 10.7 Lion

phpxampp

提问by Helton Valentini

I need to do some work on a legacy system that requires PHP 5.2

我需要在需要 PHP 5.2 的遗留系统上做一些工作

I already have XAMP 1.7.3 installed but this version has PHP 5.3.

我已经安装了 XAMP 1.7.3,但这个版本有 PHP 5.3。

Since this a work I might do for a couple of times in the next months, I was thinking about installing a XAMP version that runs PHP 5.2 At the same time I'm involved into some work that requires me to use PHP 5.3, so I just can`t uninstall my current XAMP version and install one that uses PHP 5.2

由于这是我在接下来的几个月中可能会做几次的工作,我正在考虑安装一个运行 PHP 5.2 的 XAMP 版本同时我参与了一些需要我使用 PHP 5.3 的工作,所以我只是无法卸载我当前的 XAMP 版本并安装一个使用 PHP 5.2 的版本

On XAMPP Download Websiteit's pretty clear that on installing any XAMPP version it will remove previous one. I've done some research but couldn't find a way to get around this.

XAMPP 下载网站上,很明显,在安装任何 XAMPP 版本时,它都会删除以前的版本。我做了一些研究,但找不到解决这个问题的方法。

I managed to find phpswitch under /Applications/XAMPP/xamppfiles/bin/ and using it's list action showed me that I only have PHP 5.3.1 installed and active. I tried to figured out on how to download/install/activate PHP 5.2 using phpswitch but had no success.

我设法在 /Applications/XAMPP/xamppfiles/bin/ 下找到 phpswitch 并使用它的列表操作显示我只安装了 PHP 5.3.1 并处于活动状态。我试图弄清楚如何使用 phpswitch 下载/安装/激活 PHP 5.2,但没有成功。

So what I'm looking for is a way to install multiple XAMPP or installing PHP 5.2 and activating it for XAMPP (either through phpswitch or another way)

所以我正在寻找的是一种安装多个 XAMPP 或安装 PHP 5.2 并为 XAMPP 激活它的方法(通过 phpswitch 或其他方式)

回答by NivF007

You can install parallel versions of XAMPP - one for each major version of PHP. Just don't run both at the same time.

您可以安装 XAMPP 的并行版本 - 每个主要版本的 PHP 一个。只是不要同时运行。

Install each instance of XAMPP in it's own folder.

将 XAMPP 的每个实例安装在它自己的文件夹中。

I do this under a folder called

我在一个名为的文件夹下执行此操作

XAMPPInstalls/XAMPP182-PHP54 /XAMPP183-PHP55/

XAMPPInstalls/XAMPP182-PHP54 /XAMPP183-PHP55/

In each XAMPP folder, you'll find an .exe to launch the controller for that specific XAMPP stack. I've created shortcuts to those, renamed them to 'XAMPP182-ControlPanel' and 'XAMPP183-ControlPanel' and placed those on my desktop.

在每个 XAMPP 文件夹中,您都会找到一个 .exe 来启动该特定 XAMPP 堆栈的控制器。我已经为它们创建了快捷方式,将它们重命名为“XAMPP182-ControlPanel”和“XAMPP183-ControlPanel”,并将它们放在我的桌面上。

When I need to run local site on PHP5.4, I click on XAMPP182-ControlPanel and fire up the Apache and MySQL servers.

当我需要在 PHP5.4 上运行本地站点时,我单击 XAMPP182-ControlPanel 并启动 Apache 和 MySQL 服务器。

When I need to switch a local site to PHP5.5, I click on XAMPP182-ControlPanel and shut down the Apache and MySQL servers, then I click XAMPP182-ControlPanel and fire up the Apache and MySQL servers in that stack.

当我需要将本地站点切换到 PHP5.5 时,我单击 XAMPP182-ControlPanel 并关闭 Apache 和 MySQL 服务器,然后单击 XAMPP182-ControlPanel 并启动该堆栈中的 Apache 和 MySQL 服务器。

This takes just a few seconds.

这只需几秒钟。

Also, I use 'soft-linking' so that I do all my configuration for my local web sites in one folder - then create a 'junction' (i.e. a source folder that replicates itself in the Apache configs for each XAMPP stack).

此外,我使用“软链接”,以便在一个文件夹中为我的本地网站进行所有配置 - 然后创建一个“连接”(即,在每个 XAMPP 堆栈的 Apache 配置中复制自身的源文件夹)。

There is a really good article on this called 'Practical Development 2: Working Environment' by Marco Dings in the Joomla! Community Magazine on how to set up your work environment to run multiple local XAMPP installs, multiple local web sites using 'name based hosting,' and how to keep it all organized.

Joomla 上 Marco Dings撰写的名为“实用开发 2:工作环境”的文章非常好!社区杂志关于如何设置您的工作环境以运行多个本地 XAMPP 安装、使用“基于名称的托管”的多个本地网站,以及如何保持一切井井有条。

I don't use Ding's set-up exactly - I've tweaked to get my local web projects even more organized and streamlined - but my set-up is based on Ding's approach.

我并没有完全使用 Ding 的设置——我已经进行了调整,以使我的本地 Web 项目更加有条理和精简——但我的设置是基于 Ding 的方法。

NOTE: The article, while in the Joomla! Community Magazine, is not specific to Joomla!, so you can use this set-up for whatever PHP/Apache/MySQL projects you are working on.

注意:这篇文章,在 Joomla! 社区杂志,不是特定于 Joomla!,因此您可以将此设置用于您正在处理的任何 PHP/Apache/MySQL 项目。

Now there are lots of ways to do this (e.g. using Oracle's VM Virtual Box), but that might be overkill unless you need to replicate your remote hosting environment 'exactly.' For example, if you are running a 'dedicated host' and want to closely replicate dedicated host's environment and set up as closely as possible, then you'd go with VM Virtual Box Set-Up - this allows you to run multiple VM's (i.e. different set-ups) and then clone the exact set-up to your live server. Again, overkill if most of your projects are going to 'shared hosting' environments as you don't have much control over the set-up anyways.

现在有很多方法可以做到这一点(例如使用 Oracle 的 VM Virtual Box),但除非您需要“完全”复制远程托管环境,否则这可能有点过头了。例如,如果您正在运行“专用主机”并希望密切复制专用主机的环境并尽可能地进行设置,那么您将使用 VM Virtual Box Set-Up - 这允许您运行多个 VM(即不同的设置),然后将准确的设置克隆到您的实时服务器。同样,如果您的大多数项目都将使用“共享托管”环境,那就有点矫枉过正了,因为无论如何您对设置都没有太多控制权。

Parallel installation of multiple instance of XAMPP is much much much simpler and you can set it up as per Ding's article. It should cover your requirements.

并行安装多个 XAMPP 实例要简单得多,您可以按照 Ding 的文章进行设置。它应该涵盖您的要求。

I've mentioned Oracle VM VirtualBox because you should at least know about it as an option.

我提到 Oracle VM VirtualBox 是因为您至少应该了解它作为一个选项。

回答by fells77

You could always use VirtualBox (or similar) to create an instance with 5.2 on it and then when you're done with old work, just dump the VB instance with no ill affect on your current system.

你总是可以使用 VirtualBox(或类似的)来创建一个带有 5.2 的实例,然后当你完成旧工作时,只需转储 VB 实例,而不会对当前系统产生不良影响。

回答by Martin Bean

You have a couple of options. Either use a virtual box to run virtual environments: one with PHP 5.2 and another with PHP 5.3. Or, if you're comfortable with installing PHP you could install the various version of PHP you need, and set up a symbolic link to the version you want to use at that time.

你有几个选择。要么使用虚拟机来运行虚拟环境:一个使用 PHP 5.2,另一个使用 PHP 5.3。或者,如果您对安装 PHP 感到满意,您可以安装您需要的各种 PHP 版本,并设置一个指向您当时想要使用的版本的符号链接。

回答by Douglas B. Staple

I don't know anything about Apache or PHP, but I find MacPorts helpful for installing multiple versions of software that is usually difficult to install multiple versions of, such as python or GCC.

我对 Apache 或 PHP 一无所知,但我发现 MacPorts 有助于安装通常难以安装多个版本的软件的多个版本,例如 python 或 GCC。

port search php

shows that MacPorts can provide PHP 5.2, 5.3, and 5.4. Such installations are put into /opt, so they will leave any other PHP installations alone.

显示 MacPorts 可以提供 PHP 5.2、5.3 和 5.4。此类安装被放入 /opt 中,因此它们不会影响任何其他 PHP 安装。

回答by Luca

I just want to add in case you run any os (mine is Yosemite) do the same but working on the xamppfiles folder inside the main XAMPP folder (so the path to work with is different), you can both then change configure.ini and possibly file related (complicated) or (easy but dirty) name the version you want to use xamppfiles and the other whatever, and then create 2 separate alias for the manager to start (one for each xampp version). Like this is a little confusing but if someone needs it I can describe both approaches step by step.

我只是想添加,以防您运行任何操作系统(我的是 Yosemite)做同样的事情,但在主 XAMPP 文件夹内的 xamppfiles 文件夹上工作(因此使用的路径不同),然后您都可以更改 configure.ini 和可能与文件相关(复杂)或(简单但肮脏)命名您要使用的版本 xamppfiles 和其他任何名称,然后创建 2 个单独的别名供管理器启动(每个 xampp 版本一个)。像这有点令人困惑,但如果有人需要它,我可以逐步描述这两种方法。

回答by yodarunamok

Previous answers didn't work well for me, but there's a rather elegant solution over on the Apache Friends Forum, though it took me a bit to get things working properly. Some highlights:

以前的答案对我来说效果不佳,但是在 Apache Friends Forum 上有一个相当优雅的解决方案,尽管我花了一些时间才能使事情正常工作。一些亮点:

  • By installing multiple versions of XAMPP, you can get various versions of the PHP CGI module. That said, keep in mind that your config files and databases may need to be restored if you run multiple installers, so backup and plan accordingly.
  • Make sure that those CGIs are allowed to do their thing by adding a block something like this in your httpd-xampp.conffile (I put mine at the end):

    <Directory "/Applications/XAMPP/xamppfiles/bin">
        Require all granted
        Options +ExecCGI
    </Directory>
    

    Keep in mind that depending on the version of Apache that XAMPP is using, your syntax may vary a bit.

  • Now find this section in your httpd.conffile and make sure the corresponding Includeis uncommented, like so:

    # Virtual hosts
    Include etc/extra/httpd-vhosts.conf
    
  • You can now add entries in your httpd-vhosts.conffile for each version of PHP that you want to use, something like this:

    <VirtualHost test54.yourdomain.com:80>
        ServerName test54.yourdomain.com
        ....
        ScriptAlias /xampp-bin /Applications/XAMPP/xamppfiles/bin
        <FilesMatch "\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>
        Action application/x-httpd-php /xampp-bin/php-cgi-5.4.31
        ....
    </VirtualHost>
    <VirtualHost test55.yourdomain.com:80>
        ServerName test55.yourdomain.com
        ....
        ScriptAlias /xampp-bin /Applications/XAMPP/xamppfiles/bin
        <FilesMatch "\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>
        Action application/x-httpd-php /xampp-bin/php-cgi-5.5.35
        ....
    </VirtualHost>
    ....
    

    (In the version of XAMPP that I use, there also happens to be a symbolic link in that bindirectory called simply php-cgiwhich points to the most recent CGI installed, and I add a block for that, too.)

  • Add corresponding entries to your hostsfile, like so:

    127.0.0.1           test54.yourdomain.com
    127.0.0.1           test55.yourdomain.com
    
  • 通过安装多个版本的XAMPP,您可以获得各种版本的 PHP CGI 模块。也就是说,请记住,如果您运行多个安装程序,您的配置文件和数据库可能需要恢复,因此请相应地进行备份和计划。
  • 通过在你的httpd-xampp.conf文件中添加一个类似这样的块来确保这些 CGI 被允许做他们的事情(我把我的放在最后):

    <Directory "/Applications/XAMPP/xamppfiles/bin">
        Require all granted
        Options +ExecCGI
    </Directory>
    

    请记住,根据 XAMPP 使用的 Apache 版本,您的语法可能会有所不同

  • 现在在您的httpd.conf文件中找到此部分并确保相应的Include部分未注释,如下所示:

    # Virtual hosts
    Include etc/extra/httpd-vhosts.conf
    
  • 您现在可以httpd-vhosts.conf为要使用的每个 PHP 版本在文件中添加条目,如下所示:

    <VirtualHost test54.yourdomain.com:80>
        ServerName test54.yourdomain.com
        ....
        ScriptAlias /xampp-bin /Applications/XAMPP/xamppfiles/bin
        <FilesMatch "\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>
        Action application/x-httpd-php /xampp-bin/php-cgi-5.4.31
        ....
    </VirtualHost>
    <VirtualHost test55.yourdomain.com:80>
        ServerName test55.yourdomain.com
        ....
        ScriptAlias /xampp-bin /Applications/XAMPP/xamppfiles/bin
        <FilesMatch "\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>
        Action application/x-httpd-php /xampp-bin/php-cgi-5.5.35
        ....
    </VirtualHost>
    ....
    

    (在我使用的 XAMPP 版本中,该bin目录中也恰好有一个符号链接,称为 simplephp-cgi指向最近安装的 CGI,我也为此添加了一个块。)

  • 将相应的条目添加到您的hosts文件中,如下所示:

    127.0.0.1           test54.yourdomain.com
    127.0.0.1           test55.yourdomain.com
    

That should do it. I love the resulting flexibility, and the fact that the various versions of PHP that I have configured as simply available when I need them.

那应该这样做。我喜欢由此产生的灵活性,以及​​我配置的各种 PHP 版本在我需要时可以轻松使用的事实。

回答by Amit Singh

We can use Xampp-VM for multiple xampp installation. I wanted to use multiple php versions for older and new projects without changing or wasting my time in configuration.

我们可以使用 Xampp-VM 进行多个 xampp 安装。我想为旧项目和新项目使用多个 php 版本,而无需更改或浪费我的时间进行配置。

So If your Xampp is already installed. Install new Xampp-VM from here

所以如果你的 Xampp 已经安装了。从这里安装新的 Xampp-VM

https://www.apachefriends.org/download.html

https://www.apachefriends.org/download.html

This will guide you, how to setup Xampp-Vm.

这将指导您如何设置 Xampp-Vm。

https://www.apachefriends.org/blog/new_xampp_20170628.html

https://www.apachefriends.org/blog/new_xampp_20170628.html