Wamp: installing both PHP 4 and 5 and how to switch them back and forth

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:


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


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


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.


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.

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)

64 responses to “Wamp: installing both PHP 4 and 5 and how to switch them back and forth”

  1. Ski

    Very interesting info!Perfect just what I was searching for!

  2. Office

    You have noted very interesting details ! ps nice internet site . “There’s always one who loves and one who lets himself be loved.” by W. Somerset Maugham.

  3. Designer

    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!

  4. Lisa Lauder

    Mega schön

  5. 해적맞고게임

    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.

  6. 사다리

    This article presents clear idea for the new users of blogging, that really how to do blogging and site-building.

  7. 배터리맞고게임

    Good info. Lucky me I came across your website
    by chance (stumbleupon). I’ve saved as a favorite for later!

  8. 바카라 꽁

    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.

  9. 놀이터 먹튀

    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.

  10. 인터넷 포커 게임

    Useful info. Lucky me I found your website unintentionally, and I’m stunned why this accident did not happened
    in advance! I bookmarked it.

  11. 777 무료 슬롯 머신

    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!

  12. 꽁 머니 토토

    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.

  13. 세부 카지노

    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

  14. 해외 스포츠 사이트

    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!

Leave a Reply