WampServer Multiple PHP Versions

This  document is intended for use with:
WampServer version 2.5 : Apache : 2.4.9 MySQL : 5.6.17 PHP : 5.5.12

Sometimes, you need to run multiple PHP versions for some projects using wamp.  So this time I will show you how to configure wamp server 2.5  to run several php versions(one per time). Lets start:

1. Download phpxxxxxx.zip package for windows from http://windows.php.net/downloads/releases/archives/.   i.e. php-5.3.10-Win32-VC9-x86.zip.

2. Extract it on yourpath/wamp/bin/php/php5.x.xx folder (i.e wamp/bin/php/php5.3.10/)

Lets Start the configuration. Lets go in wamp/bin/php/php5.3.10/  (working directory for steps 3 to 5)

3. Copy and paste php.ini-development and rename it to php.ini and open it for editing.
a. Search the word “extension_dir” and add the follow line
extension_dir = “C:/path/to/your/wamp/bin/php/php5.3.10/ext/”
b. Then search “upload_tmp_dir and add
upload_tmp_dir = “C:/path/to/your/wamp/tmp
c. Search “http://php.net/session.save-path” and add the follow line below it

session.save_path = “C:/path/to/your/wamp/tmp

4.  Now copy the php.ini and paste it as “phpForApache.ini” in the same folder. So you will have php.ini and phpForApache.ini.

5. Create a new file called wampserver.conf and paste the following content.

<?php
 $phpConf['phpIniDir'] = '.';
 $phpConf['phpExeDir'] = '.';
 $phpConf['phpConfFile'] = 'php.ini';

 $phpConf['apache']['1.3']['LoadModuleName'] = 'php5_module';
 $phpConf['apache']['1.3']['LoadModuleFile'] = 'php5apache.dll';
 $phpConf['apache']['1.3']['AddModule'] = 'mod_php5.c';

 $phpConf['apache']['2.0']['LoadModuleName'] = 'php5_module';
 $phpConf['apache']['2.0']['LoadModuleFile'] = 'php5apache2.dll';
 $phpConf['apache']['2.0']['AddModule'] = '';

 $phpConf['apache']['2.2']['LoadModuleName'] = 'php5_module';
 $phpConf['apache']['2.2']['LoadModuleFile'] = 'php5apache2_2.dll';
 $phpConf['apache']['2.2']['AddModule'] = '';

 $phpConf['apache']['2.4']['LoadModuleName'] = 'php5_module';
 $phpConf['apache']['2.4']['LoadModuleFile'] = 'php5apache2_4.dll';
 $phpConf['apache']['2.4']['AddModule'] = '';
?>

6. Now open C:/path/to/wamp/wampmanager.ini to tell wamp that we have another php version. Search the section [phpVersion] and add the line as follow :

Type: item; Caption: "5.3.10"; Action: multi; Actions:switchPhp5.3.10

Then search this line:

Parameters: "http://www.wampserver.com/addons_php.php";

And add the following lines below it:

[switchPhp5.3.10]
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: run; FileName: "C:/path/to/wamp/bin/php/php5.5.12/php-win.exe";Parameters: "switchPhpVersion.php 5.3.10";WorkingDir: "C:/path/to/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "C:/path/to/wamp/bin/php/php5.5.12/php-win.exe";Parameters: "-c . refresh.php";WorkingDir: "C:/path/to/wamp/scripts"; Flags: waituntilterminated
Action: run; FileName: "net"; Parameters: "start wampapache"; ShowCmd: hidden; Flags: waituntilterminated
Action: resetservices
Action: readconfig;

7.  Finally we need to make the old version of php 5.2, 5.3 ,etc compatible with apache 2.4. To do that, we need to download php5apache2.4.dll from
https://www.apachelounge.com/download/additional/,  i.e. php5apache2_4.dll-php-5.2-win32.zip .  Choose the right version for your php and extract the file php5apache2.4.dll on your new php version folder c:/path/to/wamp/bin/php/php5.3.10/

Thats all. Close wampserver and open it again. you will see the new php version to be elegible.

wamp-multi-php-version

Remember to change  C:/path/to/wamp to your wamp path.

PD: Please comment any mistake or issue.  I will try to improve this article later.  Hope, it can help someone.

Leave a Reply

Your email address will not be published. Required fields are marked *