Getting XAMPP to work with multiple version of PHP

Please note
This answer is not valid for new version of XAMPP.


First, you'll need to stop Apache from XAMPP. Then,

Go go cmd and switch to your XAMPP folder. For example, if your XAMPP folder is in C:\

C:\>cd C:\XAMPP 

In this folder is a file named php-switch.bat, run from the command line. If not, you can also run php-switch.bat directly.

You'll see the version you are now on, and procedure to switch. For example, type 4 to switch PHP 4 then follow the procedure.

php-switch.bat running in the terminal

PHP 4 will install in your XAMPP\PHP directory and successfully switch. then re-enable the Apache.


The best method is to change the PHP settings in

/apache/conf/extra/httpd-xampp.conf

to reflect the new version of PHP you want to use

In my case I unpacked PHP5.4 to C:\XAMPPLITE\PHP5.4 and then updated key lines in this file such as:

SetEnv PHPRC "C:\\xampplite\\php5.4"

LoadFile "C:/xampplite/php5.4/php5ts.dll"

PHPINIDir "C:/xampplite/php5.4"

You also need to ensure that the correct version of php5apache2_2.dll is installed

To ensure this I copied the new version of php5apache2_2.dll to the Apache modules directory with a unique name, and then modified the configuration to match that:

copy php5.4\php5apache2_2.dll apache\modules\php5apache2_2-5_4.dll

and in the httpd-xampp.conf file

LoadModule php5_module modules/php5apache2_2-5_4.dll

If your scripts are buggy, they will remain buggy no matter what server packages you switch. If the problem is in your server configs, dig right in and sort it out.

Real hardcore solution would be installing and managing server components (and their configurations) manually. Since I switched away from WAMP to self-administered server installation, I've never again felt any need for prepackaged server solutions.


If you want that feature (meaning, ability to mix and match apache, mysql, and php component builds) and prefer the 3rd Party Bundled AMP Stack Apps, you could look at WAMPServer 2.0 as an option for Windows... Pretty Much every other Bundled AMP Option I've looked at (for Windows, Mac, and Linux) don't allow for swapping out component builds (I'm not including switches of PHP4 and PHP5 as component builds as they were really only offered due to legacy code issues until PHP5 became more backward compatible and PHP4 less abundant).

Most 3rd Party Bundled AMP Stack Apps, especially Unix-based OS builds (Mac & Linux), in order to have the Stack Components within the same directory structure as the "app" root directory, they have to compile each component with specific directives and arguments which ultimately kind of hard-wires some of the folder references and binary signatures into each of the component builds themselves....specifically the mysql and php components because they have library objects that are both shared and required to be specifically referenced and included during the source compile... (and it seems to me that most don't for whatever reason just compile with every optional directive and library included... not sure that would solve the issue or not b/c I have gotten that far with my project to answer that just yet).

One other note, because it is within the same context.... in regards to the comments on using the components autonomous installs vs. the _AMPP stacks, I unfortunately only know what I wrote above because I tried to set up using the 3 autonomous components' source code and tried to have my cake and eat it to.... while never having had any experience dealing with any one of them prior.... so I can say that there are 2 very convincing reasons why Developers do and should use the Stacks for local development environments:

1) if your project is utilizing this technology but isn't explicitly extending function within any one component's core, then most just want to be up an running to be able to work on what they need to work on....and not have to figure out all the configs necessary for the 3 components to seamlessly talk to each other. One could easily struggle for days to learn which directives, modules, libraries, compilation arguments, etc. are needed. If you already know it, great, but don't recommend it to someone who doesn't unless you're gonna do it for them.

2) the bundled stacks are autonomous and isolated from the OS config files, so you can trash your devel environment without severe consequences.... if you want to run scripts that deploy files to the necessary "etc" folder, I don't know about you, but I can make a mistake from time to time and a mistake on the ../XAMPP/etc folder is far less painful then a mistake on the /etc folder.

3) GUI...GUI...GUI... not everyone is a command line Mozart and the AMPP stacks all provide a nice GUI to turn things On and Off to your heart's content. If you want a GUI, you'll gravitate toward the AMPP Stack apps... if you don't care, it all depends on how much weight or stock you put on my points #1 & #2

Anyway, sorry for the Dissertation of "How to Make Someone Yawn", hope someone gets something out of this.