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.

wamp-2

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:

wamp

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.

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

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

  1. 모 롱고 카지노

    My developer is trying to persuade me to move to .net from
    PHP. I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using Movable-type on a number
    of websites for about a year and am concerned about switching to another platform.
    I have heard excellent things about blogengine.net.
    Is there a way I can transfer all my wordpress
    posts into it? Any help would be really appreciated!

  2. 루비게임주소

    WOW just what I was searching for. Came here by searching for Programming

  3. 미국 카지노

    Unquestionably believe that which you stated.
    Your favorite reason seemed to be on the internet the easiest thing
    to keep in mind of. I say to you, I definitely get annoyed at
    the same time as other people consider concerns that they
    just do not know about. You controlled to hit the nail upon the highest as neatly as
    outlined out the whole thing without having side effect ,
    other people could take a signal. Will likely be back to get more.
    Thank you

  4. 카지노 코인

    hello!,I like your writing so a lot! percentage we communicate more about your post on AOL?
    I need a specialist in this house to solve my problem.
    May be that’s you! Looking forward to look you.

  5. 네임드 해킹 프로그램

    It’s awesome to visit this web page and reading the views of all friends regarding this paragraph,
    while I am also zealous of getting knowledge.

  6. 우리계열카지노

    Hi to every one, it’s genuinely a good for me to visit this site, it
    includes valuable Information.

  7. 홀덤

    Undeniably consider that that you stated. Your favorite justification seemed to be on the
    internet the easiest thing to take into accout of.
    I say to you, I certainly get irked at the same time as folks consider issues that they plainly don’t recognize about.

    You controlled to hit the nail upon the top and also outlined out the whole thing without having side
    effect , people can take a signal. Will likely be again to get more.
    Thank you

  8. 바다 이야기 게임 다운로드

    After looking over a number of the blog articles on your blog, I honestly like your
    way of blogging. I book-marked it to my bookmark webpage list
    and will be checking back soon. Take a look at my web site as well and let me know how you feel.

  9. 777 무료 슬롯 머신

    Hey very cool web site!! Guy .. Beautiful .. Wonderful ..

    I’ll bookmark your web site and take the feeds additionally?
    I am glad to search out numerous helpful information here in the put up, we want
    work out extra strategies in this regard, thank you for sharing.

    . . . . .

  10. https://the-krmassage.blogspot.com

    What a data of un-ambiguity and preserveness of valuable knowledge concerning unpredicted feelings.

  11. past life regressionists

    This page seems like the other page I was looking at earlier

  12. https://Aubreanna-shark.blogspot.com

    I was wondering if you ever considered changing the page layout of
    your website? Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people could connect
    with it better. Youve got an awful lot of text for only having 1 or 2 pictures.
    Maybe you could space it out better?

  13. https://Henan-kropmasasage7.blogspot.com

    Awesome! Its in fact amazing post, I have got much clear idea concerning from this paragraph.

  14. https://aged-softanma8.blogspot.com

    Remarkable! Its in fact amazing paragraph, I have got much clear
    idea about from this article.

  15. https://okchon-anma2.blogspot.com

    It is really a nice and useful piece of information. I’m glad that you shared
    this useful info with us. Please keep us informed like this.
    Thanks for sharing.

  16. https://Hapcheon-softmassage0.blogspot.com

    Great article.

  17. https://Changning-kropmasasage.blogspot.com

    I must thank you for the efforts you’ve put in penning this website.
    I’m hoping to see the same high-grade content from you later
    on as well. In fact, your creative writing abilities has inspired
    me to get my own website now ;)

  18. https://gyeongsangbuk-do-kropmasasage6.blogspot.com

    It’s an awesome paragraph in support of all
    the internet users; they will get benefit from it I am
    sure.

  19. https://copper-kropmasasage7.blogspot.com

    Hi there, after reading this amazing article i am too cheerful to share my knowledge here with friends.

  20. https://www.twopad.kr/

    Hello there! Quick question that’s entirely off
    topic. Do you know how to make your site mobile friendly?
    My site looks weird when browsing from my iphone4.

    I’m trying to find a theme or plugin that might be able to resolve this problem.
    If you have any recommendations, please share. Cheers!

  21. https://jinshan-opmassage3.blogspot.com

    What’s up it’s me, I am also visiting this web site daily, this
    web page is in fact pleasant and the users are genuinely sharing good thoughts.

  22. https://Dae-gu-softmassage3.blogspot.com

    Definitely imagine that that you stated. Your favorite reason seemed to be at the web the easiest factor to be mindful of.

    I say to you, I definitely get irked at the same time as folks think about worries that they just don’t know about.
    You controlled to hit the nail upon the highest as well as outlined out the entire thing without having side effect , other folks can take a
    signal. Will likely be back to get more. Thanks

  23. https://Sancheong-softanma8.blogspot.com

    This design is wicked! You certainly know how to keep a reader entertained.
    Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent
    job. I really enjoyed what you had to say, and more than that,
    how you presented it. Too cool!

  24. https://Magdalena-marmot.blogspot.com

    I don’t even know the way I stopped up here, however I thought
    this put up was good. I do not understand who you’re but certainly you’re going to a famous blogger for those who aren’t
    already. Cheers!

  25. https://Corbin-gazelle.blogspot.com

    Hey excellent blog! Does running a blog like
    this require a large amount of work? I’ve absolutely no understanding of programming but I
    had been hoping to start my own blog soon. Anyways, if you have
    any recommendations or tips for new blog owners please share.
    I know this is off subject but I simply had to ask. Thanks!

  26. https://anchovy-Sam.blogspot.com

    This article is actually a pleasant one it assists new net viewers, who are
    wishing in favor of blogging.

  27. https://Anjali-bullfrog.blogspot.com

    I have to thank you for the efforts you have put in penning this blog.
    I’m hoping to see the same high-grade blog posts by you later on as well.

    In fact, your creative writing abilities has
    encouraged me to get my own blog now ;)

  28. https://hongcheon-softanma.blogspot.com

    Hey, I think your site might be having browser compatibility issues.
    When I look at your blog in Firefox, it looks fine but when opening in Internet Explorer,
    it has some overlapping. I just wanted to give
    you a quick heads up! Other then that, amazing blog!

  29. https://Carlene-Crab.blogspot.com

    Thanks for the marvelous posting! I quite enjoyed reading it, you may be a great author.
    I will make sure to bookmark your blog and will eventually come back in the future.
    I want to encourage you continue your great work, have a nice evening!

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

  31. https://www.bestsns.kr/

    Thanks for sharing your thoughts on Programming.
    Regards

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

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

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

  35. Tattoo

    your e-mail subscription hyperlink or newsletter service.

  36. 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!

  37. 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?

  38. dyson vacuum parts

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

  39. vipin kumar

    nice

  40. here

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

  41. clash of clans tips th7

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

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

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

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

  45. 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,
    etc.

  46. 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. […]

  47. xinwei

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

  48. mohamed

    merci beaucoup :)

  49. Benny Helander

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

  50. 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!!!

    Regards

    Tiago Cariolano

Leave a Reply