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