This post will be for Wamp server users. I will explain, how to have both PHP 4 and 5 installed, and switch them at any time.
Wamp server is a brilliant tool for web developers (sadly it is Windows-only). It takes care of installing the big 3 (so you don’t have to do it manually):
- Apache web server
- PHP scripting language module for Apache
- MySQL database server
And the installation is pretty easy and straightforward. But the really cool part, is the two click configuration of Wamp. After you install it, it sits in the Windows system tray. If you want to enable/disable an Apache module or change a PHP setting, all you have to do is click on the system tray icon of Wamp, then go to the menu of the respective application, dive into Apache modules, or PHP settings/extensions, and just put/remove a tick next to the setting you want changed. That’s it! No need for searching for configuration files and modifying them. The webserver is also automatically restarted, to make sure your changes are applied. And even when you will really need the configuration files, they will be accessible from the same menu.
Now, all the above will probably be nothing new for most of the PHP developers working on Windows. But if you have to work with legacy PHP 4 only projects, read on.
Installing PHP 4 on Wamp is actually very simple, just like everything else. You can grab the PHP 4 add-on for Wamp from here: http://www.wampserver.com/en/addons_php.php
You will also need to grab the add-on for Apache 2.0.x server (since the 2.2.x versions don’t work with PHP 4) from here: http://www.wampserver.com/en/addons_apache.php
Download them, install them and you will have them available from the Wamp tray icon menu:
So now you have both PHP 4 and 5 installed on your server. But there is one problem left, and that problem is that switching between these two versions of PHP is not as simple as everything above. Even though you can still try to use the tray icon menu to switch between them, i couldn’t get it to work, and sometimes Wamp would just start throwing bogus error messages.
The workaround for this, is to use a separate script for switching between the two versions. Create 3 files in your c:\wamp directory (or wherever you installed Wamp to): 4_install.bat, 5_ install.bat and remove.bat . These are the contents of these 3 scripts (just replace {apache 2.0.x directory}, {apache 2.2.x directory} and {mysql 5.1.x directory} with their respective directory names:
4_install.bat:
bin\apache\{apache 2.0.x directory}\bin\Apache.exe -k install -n wampapache NET START wampapache .\bin\mysql\{mysql 5.1.x directory}\bin\mysqld.exe --install wampmysqld NET START wampmysqld start wampmanager.exe
5_install.bat:
bin\apache\{apache 2.2.x directory}\bin\httpd.exe -k install -n wampapache NET START wampapache bin\mysql\{mysql 5.1.x directory}\bin\mysqld.exe --install wampmysqld NET START wampmysqld start wampmanager.exe
remove.bat:
NET STOP wampapache bin\apache\{apache 2.2.x directory}\bin\httpd.exe -k uninstall -n wampapache NET STOP wampmysqld .\bin\mysql\{mysql 5.1.x directory}\bin\mysqld.exe --remove wampmysqld wampmanager.exe -quit -id={wampserver}
Now, if you are running PHP 5, and you suddenly need PHP 4, all you need to do, is run remove.bat and then 4_install.bat. And when you need to switch back, run remove.bat and then 5_install.bat. Simple.
Note:
You might get an error, similar to this one, when running 4_install.bat :
Syntax error on line XXX of C:/wamp/bin/apache/apache2.0.63/conf/httpd.conf: Cannot load C:/wamp/bin/php/php4.4.9/sapi/php4apache2.dll into server: The specified module could not be found.
This means, that Apache was unable to load PHP4 module. This could happen for 2 reasons:
- Path to module may be wrongly specified. Open bin\apache\{apache 2.0.x directory}\conf\httpd.conf, scroll somewhere near lines 130-170. You should see a bunch of LoadModule directives. At the end of this bunch, there should be the one which loads PHP module. The line should say:
LoadModule php4_module “c:/wamp/bin/php/php4.4.9/sapi/php4apache2.dll”
Note that, module name has to be php4_module, and NOT php5_module. Also note, that the path to the file has to be correct (check for correct PHP version).
- PHPIniDir may be unset. Search for the directive PHPIniDir in the httpd.conf file. It should say:
PHPIniDir “c:/wamp/bin/apache/{apache 2.0.x directory}/bin/”
If you won’t find it, add it after the LoadModule lines.
After these two things will be fixed, run 4_install.bat again.
Also note, that phpMyAdmin 3.x versions currently bundled with Wamp server do not work with PHP versions lower than 5.2, so you might consider using an older version of phpMyAdmin (2.x) instead, if you will need to switch to PHP4 often.
A neat idea:
http://scratch.mit.edu/ <– some people at MIT created this wonderful tool called Scratch, which presents the basic concepts of programming in a childish and playfull manner, which is suitable for kids. With scratch, you can construct a basic program by adding predefined code blocks on top of one another. You can create loops, conditionals and so on. This is really nice, especially now, when kids seem to have lost the desire or curiosity to learn programming, the use of such a tool may be very powerful in helping kids to get the basics of programming and helping them obtain the way of analytical thinking necessary to be successful at programming. It is suited for kids from age 8 and up.
Great site. Lots of helpful info here. I am sending it to a few friends ans also sharing in delicious. And obviously, thanks to your sweat!
Mega schön
I got this website from my pal who informed me concerning this web site and
at the moment this time I am visiting this web site and
reading very informative articles or reviews here.
This article presents clear idea for the new users of blogging, that really how to do blogging and site-building.
Good info. Lucky me I came across your website
by chance (stumbleupon). I’ve saved as a favorite for later!
Great post. I was checking constantly this blog and I’m impressed!
Extremely useful info particularly the last part :)
I care for such info much. I was looking for this particular info for a very long
time. Thank you and good luck.
I loved as much as you’ll receive carried out right here. The sketch
is tasteful, your authored subject matter stylish.
nonetheless, you command get got an nervousness over that you wish be delivering the following.
unwell unquestionably come more formerly again as exactly the
same nearly very often inside case you shield this hike.
Useful info. Lucky me I found your website unintentionally, and I’m stunned why this accident did not happened
in advance! I bookmarked it.
Having read this I believed it was extremely informative.
I appreciate you spending some time and effort to put this short article together.
I once again find myself personally spending way too much
time both reading and leaving comments. But so what,
it was still worth it!
Quality articles or reviews is the main to attract the users to pay a visit the web site, that’s what this site is providing.
Nice blog here! Additionally your website lots up fast! What host are you using?
Can I am getting your affiliate link on your host?
I wish my website loaded up as quickly as yours lol
I do not even know the way I stopped up here, but I believed this put up used
to be great. I do not know who you are but certainly you’re going to a
well-known blogger should you are not already. Cheers!