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)

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

  1. https://Gordon-catta.blogspot.com

    I do believe all the concepts you have presented for your post.
    They’re really convincing and will definitely work.
    Nonetheless, the posts are very brief for novices. Could you please extend them a bit from next time?
    Thanks for the post.

  2. https://www.bestsns.kr/

    Thanks for sharing your thoughts on Programming.

  3. https://jinan-krmassage.blogspot.com

    I’m pretty pleased to discover this website.
    I need to to thank you for your time just for this wonderful read!!

    I definitely really liked every little bit of it and
    i also have you book marked to check out new things in your blog.

  4. https://namwon-opmassage.blogspot.com

    What’s up to all, for the reason that I am truly eager of
    reading this blog’s post to be updated regularly. It contains good information.

  5. taylor swift

    I’а†ve read some good stuff here. Certainly price bookmarking for revisiting. I surprise how a lot attempt you set to create one of these excellent informative site.

  6. Tattoo

    your e-mail subscription hyperlink or newsletter service.

  7. chocopie

    TH2gkZ This is a great tip especially to those new to the blogosphere. Short but very accurate information Many thanks for sharing this one. A must read article!

  8. Noella

    Wriote moгe, thats alll I havce tߋ saу.
    Literally, іt serms ɑѕ thouǥh you relied on the video to ake ʏour poіnt.

    You obvioᥙsly knw whjat yoᥙre talking ɑbout, why throw аwaу ʏouг intelligence on jսѕt posting videos
    tо your site wһen you сould bee ցiving us someyhing enlightening tо гead?

  9. dyson vacuum parts

    I couldn’t refrain from commenting. Excceptionally well written!

  10. vipin kumar


  11. here

    Very shortly this site will be famous among all blogging visitors, due to it’s pleasant articles

  12. clash of clans tips th7

    They’ve made the app very resistant against anyone attempting to take a couple of gems.

  13. Google

    is updated frequently with free advice about Google
    Ad – Words strategy, tactics, tips tricks and
    techniques for success in Ad – Words advertising.
    This will allow you to answer only those calls
    that come in on your forwarded toll free number and route other calls to different locations.
    And then on March 20, the world’s largest paid private blog network – BMR
    - announced that its vast network had been almost entirely de-indexed by Google, causing chaos in the internet marketing industries.

  14. Google

    Sooner or later, Google will find all new spam methods.
    It has the highest ROI (Return of Invesment) in all advertisement channels.
    But it seems Memorial Day wasn’t important enough
    to Google.

  15. Georgina

    It will also increase the ranking of your website on search engines and will drive more traffic to your website.
    It has the highest ROI (Return of Invesment) in all advertisement channels.
    The only tab of your concern is Public Templates, and no actions are necessary as it is already on the screen.

  16. candyblastmania462.wordpress.com

    There are two versions, one written in Python and one written in Objective C targeting i
    - OS. Rich client side business logic can often lead to unexpected security pitfalls.
    We also have expert teams working on other flash application development applications
    such as social networking websites, information websites,

  17. Faire cohabiter php 4 et php 5 sur un serveur apache | Développeuse Informatique Développeuse Informatique Faire cohabiter php 4 et php 5 sur un serveur apache Développeuse Informatique |

    […] Je me suis inspirée de cet article pour écrire le mien: article. […]

  18. xinwei

    Thanks for sharing, please maintain an update about this info. adore to read it more. i like this website too much. Good theme .

  19. mohamed

    merci beaucoup :)

  20. Benny Helander

    Tanks for the script. Realy nice and swift way to switch PHP.

  21. Tiago Cariolano de Souza Xavier

    Dear Kipras,

    Thank you very much, your post is a excellent. It helped me a lot. Thank you very much, I really nedded of the php4. You have been incredible. Thank you very much again.

    Success for you!!!


    Tiago Cariolano

Leave a Reply