Am having a trouble running the code written for targeted PHP version 5.3. Currently I have PHP version 5.5.12 on my PC. Is there a way to have more than version on the same machine or What should I do to have those codes running perfectly fine. Am using WAMP server . Thanks
I tried to follow this article but I got stuck on how to install older versions manually . Article Link
The big advantage of WAMPServer over all the other WAMP Stack options is that it can support multiple versions of Apache/MySQL/PHP and allows you to switch between either of the 3 at will, assuming basic compatibility between compilers and linkages ( one of each at any one time of course ).
So assuming you want to use a version of PHP5.3 that is compatible with Apache 2.4 like 5.3.28+ all you need to do is manually install a version of PHP into your WAMPServer2.5.
HOW TO MANUALLY INSTALL A NEW RELEASE OF PHP INTO THE WAMP ENVIRONMENT
Before you start
On Apache and PHP you will see the acronyms VC6, VC9, VC10 or VC11. This denotes the compiler version used to compile that program or dll. Unfortunately you cannot mix the two when it comes to Apache and PHP as it is configured in WAMPServer, although some documentation suggestst that VC10 and VC11 are compatible with each other, I make no guarantee of this. So first you must find out which compiler was used to compile the Apache you are currently using, so you can get the PHP that was compiled with the same version of the compiler.
As time goes on this becomes more complicated as newer versions of PHP are not being compiled and linked with older versions of the compilers. VC6 seems to have been dropped a little while ago. So if you want to use a new PHP you will probably have to upgrade your version of Apache as well so you have a version that is compiled with at least VC9
The way PHP and Apache interact in the default WAMPServer install is that Apache launches the PHP Interpereter as a dll (php5apachex_y.dll) as this is a very close relationship i.e. not communication via a TCP port like PHP and MySQL, so they both have to have been compiled using the same version of Microsoft Visual C Compiler.
From WampManager "Stop All Services".
Download the PHP Release you want to install from HERE or if its not a current release from The Achives You should use the Thread Safe build. Usually the Not Thread Safe version has the acronim NTS and the thread safe version has TS or nothing. You should download the ZIP and not an .msi Make sure its built with the same compiler versions as you Apache ( VC6 / VC9 / VC10 / VC11 ), yes its a mine field. But if you are using WAMPServer 2.5 or > then you want the VC11 Thread Safe version, but versions compiled with VC9 and VC10 may also work.
Create a new folder under c:\wamp\bin\php\ with the name = the version you are installing so, for example, make a folder called php5.5.11.
Now from the folder containing your most recent ( and working ) verions of PHP copy the file called wampserver.conf and paste it into your new PHP folder created in the previous setup. This file is required by wamp server to properly identify that this is a valid PHP version folder. The file contains references to the names of the dll files that contain the PHP interpreter, so that the correct file can be copied to the Apache folder when you activate this new version of the PHP interpreter.
The file should look like this, if you are moving from a very old version of PHP you may need to add some new sections from here to your file.
<?php
$phpConf['phpIniDir'] = '.';
$phpConf['phpExeDir'] = '.';
$phpConf['phpConfFile'] = 'php.ini';
$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'] = '';
?>
More recent versions of PHP i.e PHP6.5 and above are not compiled to work with Apache 2.2 so you should change the file to look like This
<?php
$phpConf['phpIniDir'] = '.';
$phpConf['phpExeDir'] = '.';
$phpConf['phpConfFile'] = 'php.ini';
$phpConf['apache']['2.4']['LoadModuleName'] = 'php5_module';
$phpConf['apache']['2.4']['LoadModuleFile'] = 'php5apache2_4.dll';
$phpConf['apache']['2.4']['AddModule'] = '';
?>
Now unzip the downloaded PHP into your new folder, make sure the folder hierarchy looks like the existsing hierarchy in an existing version of PHP.
Now in your new folder copy the file 'php.ini_development' into a new file called 'php.ini'
Do the same again but paste into a file called 'phpForApache.ini'
You should now have the original file called php.ini_development PLUS 2 more, one called 'php.ini' and one called 'phpForApache.ini'
The 'php.ini' file is used if you are using the PHP CLI i.e. running php from the command line '> php script.php' The phpForApache.ini is the php config used by Apache. This file is copied into the currently active Apache's folder and renamed to php.ini by WAMPManager when you activate this version of PHP.
We must now make some change to the php.ini files to WAMPise them. Take your time here it will save you time later. Edit the newly created 'phpForApache.ini' file and Search for extension_dir and change to
extension_dir = "d:/wamp/bin/php/phpx.y.z/ext/" <- where x,y,z match the folder you are putting the new PHP into.
Search for
error_log = php_errors.log
and change to
error_log = c:\wamp\logs\php_errors.log
Search for anything 'php/' and make sure you change it to you c:\wamp\bin\php\php.x.y.z folder name.
In fact search for anything with a C:\ in it and make sure its changed to the WAMPServer equivalent.
As of PHP5.4 the timezone need to be set Search for 'timezone' and put an entry into the 'date.timezone' field as a minimum
date.timezone = "Europe/London"
date.default_latitude = 0.0
date.default_longitude = 51.502973
look here for a list of supported timezone values 'http://www.php.net/manual/en/timezones.php'
PHP5.5 specific changes
All the PHP extensions are commented out, so you need to manually uncomment at least some of them
Check your last used php.ini to see what you need, remember some extensions may have been included in the core of php so you may need to check the php change log for details.
Now there may well be other configuration changes you had made to your existing PHP, these you will have to find and transfer yourself. I suggest you compare your last \wamp\bin\apache\apachex.y.z\bin\php.ini with this new one and move over anything you believe is relevant.
DONT FORGET, if you are using the PHP CLI you will also need to do this to the php.ini file as well.
Make sure all services are stopped in wampmanager, and then right click over the wamp manager icon in the system tray and select the 'refresh' menu item.
When you left click on wamp manager -> PHP -> Version you should see your new version in the list.
If the new version does not appear, then you have probably spelt the phpForApache.ini file name wrong. Correct it and redo the 'refresh'.
You can now 'restart all services' from the wamp manager menus.
NOTE: You have not actually changed anything yet, so if WAMPServer,Apache,PHP etc were working before they still should be.
Activate your new PHP version.
Using the wamp manager menus again you just need to click on the new version number to activate it.
wamp manager -> PHP -> Version -> 5.5.11 <- or whatever the version number is you have just added
This will cause wamp manager to :-
If the wamp manager icon stays ORANGE, then you have missed something, probably a file name spelt wrong. The phpForApache.ini file must exists.
Now run localhost from the wamp manager menu, and check the wamp server home page. It should tell you which version of PHP is loaded.
[img]http://derp.co.uk/27aaf[/img]
TROUBLE SHOOTING If it all goes wrong when you activate the new PHP, you can easily back out of trouble by just activating whatever version of PHP you were using before, and then going back to see what you did wrong.
ADDING XDEBUG
XDEBUG comes with WAMP Server and is incredibly useful for debugging CLI or WEB scripts. But it does not come with the PHP you have downloaded from the PHP website. When upgrading PHP to a major version release you may need to get an up to date version of xdebug from 'http://xdebug.org/download.php' For a minor version upgrade you can probably use the existing xdebug version you already have on disk.
So for a minor PHP version upgrade, copy the folder 'c:\wamp\bin\php\php5.y.z\zend_ext' from your old PHP to your new php folder.
For a major PHP version upgrade get a new dll from the xdebug website and put it in a newly created folder called 'c:\wamp\bin\php\php5.y.z\zend_ext'
Now add a line like this ( version specific of course ) to your php.ini ( using the wamp manager menus, to ensure you are editing the correct file )
;XDEBUG Extension
zend_extension = "d:/wamp/bin/php/phpx.y.z/zend_ext/php_xdebug-2.2.2-5.3-vc9.dll"
[xdebug]
xdebug.remote_enable = off
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "d:/wamp/tmp"