Thursday, March 24, 2011

Because 5.2 is the new 4.4

I was doing a quick technology update today, checking out some of the websites of some of the tech I was using in my day to day projects, when I came across the quote in the title.  It was found on the website of Andy Dawson, otherwise known as AD7six. It's referring to PHP versions, and how PHP 5.2 is going to be defunct.

Yeah, see that strike through?  My next visit was the PHP.net site, and with their announcement of PHP 5.3.6 is also the announcement that PHP 5.2.x is no longer supported, making PHP 5.2.17 the final stable release of the PHP 5.2 series.  This was announced on 17 March, 2011.

So what does that mean for me?  Well, all of my projects are written in PHP 5.2.  At a guess, none of our production environments are running the latest of the 5.2 series.  This means I need to come up with a development environment that can support both versions of PHP, and start doing new projects in PHP 5.3, and also migrate some of our maintained projects to PHP 5.3.

So, today, I started with the development environment task of running PHP 5.3 and PHP 5.2 at the same time.

First things first, you can not run two versions of PHP 5 in the same Apache installation.  So, my solution is to create two Apache installations on my machine.  Given that I use the office DNS to allow unique host names for all my projects, and I don't want to have to specify a different port for one or the other Apache installations, I opted for installing a second IP on my NIC.

When specifying a second IP, they'll both need to be static.  If your IP was previously dynamic through DHCP, make sure you take your nominated IPs out of the dynamic range, and document the static IP allocation.  Now go to your Properties for TCPv4, and specify the primary IP address, mask and DNS servers.  Then click Advanced and enter the second IP.  In my case, both IPs are in the same subnet.  Remember to enable NetBios over TCP if this was something typically enabled by your DHCP server.

Next, you'll want to configure your Apache installations.  Because each installation will be listening to a specific IP, you'll need to specify that IP where ever you see the Listen directive.

So in my primary Apache installation, I used to have "Listen 80".  I replaced that with "Listen 192.168.174.8:80" and because it's my primary install, I'd also follow this up with a "Listen 127.0.0.1:80" to catch localhost traffic.  Remember to do the same thing with any other Listen directives, including the SSL config file.

In my secondary Apache installation, I replaced "Listen 80" with "Listen 192.168.174.88:80" and did the same thing with the other Listen directives.

I make extensive usage of virtual hosts in my development environment.  I'm also lazy and copied my primary Apache installation to be my secondary Apache installation.  Make sure you comment out any vhost entries that you don't need, change any references to the old PHP version, to the new PHP version and copy the appropriate programs from the PHP install to the Apache/bin install.  If you use a PHPIniDir directive, remember to update that.  Also remember to rename any log files that may clash between the two Apache installs.

I had a bit of trouble with IP and port clashes.  I had port 7000 used in a couple of my projects, but had not altered the Listen directive.  To help see what was going on, I used the SysInternals TCPView to view what processes were listening to what ports, and which IP addresses they were bound to.  If you're still having troubles starting one of the web servers, try starting it from the command line to see what the issue is.  Also, when you install the second Apache install as a service, remember to give it a different name.

With my recent Windows 7 install, I've been using WAMP instead of XAMPP.  In this particular installation, I have PHP versions 5.2.11 and 5.3.5.  With the recent PHP announcement, I'll be looking to update to 5.2.17 and 5.3.6 respectively.  But here's the rub.

The PHP team have also announced that they will no longer be providing PHP builds using Visual Studio C++ 6.  It will all be done with Visual Studio C++ 9.  This means I'll also need an Apache install that has been built with VS C++ 9 as well.  At least PHP have recommended Apache Lounge to source this from, but it's going to be a major spanner in the works for the likes of WAMP and XAMPP who typically provide VC6 builds.

I'm not looking forward to doing another Apache install, just so I can update to 5.3.6.  At least the PHP 5.2.17 binaries will be staying at VC6, but have no option for VC9 (so you will need two separate installs of Apache, and wont be able to get away with copying one install for the other version of PHP).

1 comment:

  1. Anything about WAMP that sells itself ahead of XAMPP?

    ReplyDelete