Upgrade PHP version
Posted by: awalls (---.range109-153.btcentralplus.com)
Date: March 26, 2013 04:12PM

Hi,

I am running WampServer 2.2 which came pre-built with PHP5.3.10. Looking at the file list on Sourceforge:

[sourceforge.net]

The latest version of 5.3 that can be installed is 5.3.1. However if I wanted to upgrade to a later version of 5.3 i.e. > 5.3.10 how can I go about this?

Thanks.

Options: ReplyQuote
Re: Upgrade PHP version
Posted by: RiggsFolly (---.as13285.net)
Date: March 27, 2013 10:25AM

Before you start

On Apache and PHP you will see the acronym VC6 and VC9. This denotes the compiler version used to compile that program or dll. It stands for Visual C V6 or Visual C V9.
Unfortunately you cannot mix the two when it comes to Apache and PHP.
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.

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.


1. From WampManager "Stop All Services".

2. Download the PHP Release you want to install from www.php.net/download
You should use the Thread Safe build.
Make sure its built with the same compiler versions as you Apache ( VC6 or VC9 )

3. Create a new folder under c:\wamp\bin\php\ with the name = the version you are installing
So make a folder called php5.5.11 for example.

4. 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 setp.
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.

5. Now unzip the downloaded PHP into your new folder, make sure the folder hierarchy looks like this.


6. 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 WAMPmaneger when you activate this version of PHP.

It should look something like this:


7. We must now make some change to the php.ini files to WAMPise them.
Edit the newly created phpForApache.ini file

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.

As of PHP5.4 the timezone needd to be set
Search for [Date] 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 [www.php.net]

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 phpForApache.ini with this new one and move over anything you believe is relevant.



8. 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 pgpForApache.ini file name wrong. Correct it and redo the 'refresh'.

9. You can now 'restart all services' from the wamp manager menus.

NOTE: You have not actually changed anything yet, so if wamp,Apache,PHP etc were working before they still should be.

10. 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 stop Apache ( the icon will go Orange )
Copy the correct files from the PHP folder to the Apache folder
php5apachex_y.dll, the php interpreter dll used by Apache
phpForApache.ini the php config file
etc

And then restart Apache. So the wamp manager icon should go GREEN again.

If the wamp manager icon stays ORANGE, then you have missed something, probably a file name spelt wrong. The phpForApache.ini file must exists.

11. 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.




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 IONCUBE

You must ensure that you download the correct version to match your PHP :-
compiler( VC6 or VC9 ) compiled ionCube dll
correct 32 or 64 bit code
and the Thread Safe version which is the one that is NOT NON-TS


1. Download the correct ionCube loader from [www.ioncube.com]
2. Place it somewhere on your disk, but not in the WAMP folder.
for example c:\webstuff\ioncube\vc9\
2. Edit the new php.ini Using the wamp manager menus
Add these 2 lines at the bottom of the file.
Remeber the version you load will depend upon which version of PHP you are using.

;ioncube Extension
zend_extension = "c:/webstuff/ioncube/vc9/ioncube_loader_win_5.3.dll"



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 this line 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.0-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"



EXTRA INFO


uncomment your extensions
Set a timezone
date.timezone = "Europe/London"
date.default_latitude = 0.0
date.default_longitude = 51.502973

Options: ReplyQuote
Re: Upgrade PHP version
Posted by: awalls (---.range109-153.btcentralplus.com)
Date: March 27, 2013 03:33PM

Brilliant, that worked perfectly. Thanks for a very detailed explanation. This is a great guide. Apologies if I missed it else where but this should be made sticky in the forum.

Just out of curiosity do you know when the guys decide to built a Wamp extension for newer PHP versions so it's just a simple install? Though in fairness it's pretty straight forward using the method above.

Options: ReplyQuote
Re: Upgrade PHP version
Posted by: RiggsFolly (---.as13285.net)
Date: March 27, 2013 04:15PM

Sorry no. I have no connection with people at Alter Way who own/maintain Wamp.

I keep meaning to contact them and suggest I give them a hand so we can get a full set of addons built but work keeps getting in the way.

Options: ReplyQuote
Re: Upgrade PHP version
Posted by: awalls (---.range109-153.btcentralplus.com)
Date: March 27, 2013 05:12PM

Understand how it is. It would be really useful if there was a full set of addons available for a quick install. Thanks again for this, managed to get PHP5.4.13 running and all appears to be happy.

Options: ReplyQuote
Re: Upgrade PHP version
Posted by: Daremo (---.ummhc.org)
Date: April 01, 2013 09:02PM

This part of your guide is confusing

"10. 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 stop Apache ( the icon will go Orange )
Copy the correct files from the PHP folder to the Apache folder
php5apachex_y.dll, the php interpreter dll used by Apache
phpForApache.ini the php config file
etc

And then restart Apache. So the wamp manager icon should go GREEN again.

If the wamp manager icon stays ORANGE, then you have missed something, probably a file name spelt wrong. The phpForApache.ini file must exists. "

Specifically the part about copying the correct files from the PHP folder to the apache folder. Can you explain that a little more? I understand you have to pick the correct php5 handler for the version of apache your running, but i must be missing something here.

Thanks!

Options: ReplyQuote
Re: Upgrade PHP version
Posted by: RiggsFolly (---.as13285.net)
Date: April 02, 2013 11:28AM

Hi Daremo,

When you click on a different version of PHP, WAMP has to do a few things to activate that selected PHP version into the current Apache.

1. it copies the php.ini file from the current Apache version folder to the old php.x.y.z/phpForApache.ini
Thus saving any changes to the php config you may have made during its lifetime so that re-activating that mix of Apache and PHP will re-activate in the same state.

2. It copies the phpForApache.ini from the NEW php folder you are trying to activate into php.ini in the current Apache folder.

3. It edits the httpd.conf file of the currently active Apache to load ( LoadModule ) the correct php5Apache2_X.dll file from the new PHPx.y.z folder to match the version of Apache and PHP you are trying to activate.


I was going to send you a PM, after I made the changes on your system via TV so you could upgrade to Apache 2.4.x I did some testing locally and found these problems and solutions to them, I hope this is self explanitory and easy to follow.





HOWTO: Switch between versions of Apache 2.2.x and Apache 2.4.x

If you are like me, a jobbing developer, you are likely to need to switch between various versions of Apache with each new job you take on in order to mimic the actual live server you are developing for at any one time. Afterall thats probably one of the reasons you use WAMP and not one of the other similiar tools available.

Now you may be coming at this from a different direction to me. I started with a WAMP 2.2E that came with Apache 2.2.x and I wanted to move to Apache 2.4.x. If however you have installed the latest versions of WAMP you may have Apache 2.4.x installed and want to step back to a version of Apache 2.2.x. If that is the case you will just have to approach what follows with that in mind and make similiar but opposite changes to get to where you want to be.

There are a few issues that I have discovered when you need to switch between Apache 2.2 and Apache 2.4 that were obviously never envisaged by the developers of WAMP.
Here are the issues I found and the solutions I came up with. They may not be perfect but they can be done without needing to get to deep into the workings of WAMP and therefore should be quite within the capabilities of anybody who uses WAMP without needing to dive to deeply into WAMPS internal workings.

ISSUES:
1. Apache 2.2 and 2.4 use a different syntax for allowing/resticting access to a site.
i.e. Apache 2.2 uses Allow/Deny and Apache 2.4 uses Require

This is going to make accessing all the standard Alias's and probably your Virtual Hosts fail when switching between the two.

Apache 2.2 uses this syntax
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
While Apache 2.4 uses this syntax for the equivalent access
Require local

And if you dont change it specific to the version of Apache you want to run at any one time you will get the good old 'You dont have rights to access' error, or possibly worse, Apache will fail to start.


So for example the phpMyAdmin Alias has this definition for its Alias and Apache2.2's access rights to the folder that it lives in.
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin3.5.1/"
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order Deny,Allow
	Deny from all
	Allow from 127.0.0.1
</Directory>

While Apache 2.4 needs this definition for its Alias to work properly
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin3.5.1/"
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Require local
</Directory>

This of course applies to all the standard alias's which are all defined in the same way.

How do I solve this I hear you cry.
Well I did this, its only a suggestion but it works.

a. Create a new folder at the same level as c:\wamp\alias and call it c:\wamp\alias24
b. Copy all the files in c:\wamp\alias to c:\wamp\alias24
c. Change all the old syntax to the new syntax in all the files in the new alias24 folder.
d. In your c:\wamp\bin\apache\apache2.4.x\conf folder(s) change the httpd.conf
there should be a line as the bottom of this file that looks like this
Include "c:/wamp/alias/*"
Change that to say
Include "c:/wamp/alias24/*"

You should now be able to switch between versions of Apache 2.2 and Apache 2.4 and your alias's will work in both versions of Apache.

This of course also applies to any Virtual Hosts you have defined.

Luckily the Virtual Hosts definitions are all stored under the Apache.x.y.z folder in a folder called 'extra' in a file called 'httpd-vhosts.conf', assuming you have used the standard mechanism for defining you vhosts. So all you need to do is go and change the syntax for each vhost defined in that file for each version of Apache 2.4.x that you have on your system



The Put Online / Put Offline feature will no longer work
NO SOLUTION TO THIS YET
I dont use it anyway as all my sites are vhosts and have there own access rights allocated within the vhost definition.
I always leave WAMP Offline as online/offline is irrelevant when you place access rights into the vhost definition!

Options: ReplyQuote


Sorry, only registered users may post in this forum.