简体   繁体   中英

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

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

I already have XAMP 1.7.3 installed but this version has 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

On XAMPP Download Website it'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.

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.

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)

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

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

I do this under a folder called

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.

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

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.

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' (ie a source folder that replicates itself in the Apache configs for each XAMPP stack).

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.

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.

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.

Now there are lots of ways to do this (eg 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 (ie 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.

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.

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

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

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.

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.

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.

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.

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:

  • 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.conf file (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.conf file and make sure the corresponding Include is uncommented, like so:

     # Virtual hosts Include etc/extra/httpd-vhosts.conf 
  • You can now add entries in your httpd-vhosts.conf file 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 bin directory called simply php-cgi which points to the most recent CGI installed, and I add a block for that, too.)

  • Add corresponding entries to your hosts file, like so:

     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.

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.

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

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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