Running PHP 4 and 5 in parallel

Discussion in 'PHP' started by Sasa, Jun 19, 2006.

  1. Sasa

    Sasa Member

    Hi there,

    this is my first post here. I am having another look at litespeed and really like what I am seeing so far. Now to my question.

    I am wondering how to run both PHP 4 and 5 on the same server. I have about 30 vhosts on this one machine (still running apache) of which I want to run most sites on PHP 5. But there are a couple of older sites which I have no time to port to PHP 5. Running PHP 4 and 5 on the same Apache instance is a real pain and so I am wondering on how to do it with lsws since I really want to migrate all my PHP development to version 5.1.x.

    Any hints?
  2. xing

    xing LiteSpeed Staff

    With litespeed you can easily mix and max different version of existing backend technologies:

    1) Define both "PHP4" and "PHP5" instances in "External Applications".

    2) Use script handlers to give "PHP4" to scripts named php or php4 and "PHP5" workers to scripts named php5.
    Last edited: Jun 19, 2006
  3. ts77

    ts77 Well-Known Member

    I'm actually running both php-versions because of the same very reason, legacy applications :).

    Go with 1), define both php-installs as handlers in external applications (the big difference to apache is that they run as fastcgi, not module)
    and override the global script handlers for each vhost the way you want, so you can use .php for php4 in one host, .php for php5 in another host.
  4. Sasa

    Sasa Member

    Good to know. Now I have no excuse to not actually try it out ;)

    I knew that you could do that with FastCGI. You can use any webserver that supports FastCGI to do this. I guess I should have asked if the lsapi supports this. I tried to lear more about it, but could only find a dead link to

    So, can lsapi do it or do I have to use FastCGI for this?
  5. mistwang

    mistwang LiteSpeed Staff

    Yes, you can use lsapi, it works in the similar way as FastCGI, just faster due to the optimization in protocol.
  6. xing

    xing LiteSpeed Staff


    Thanks for pointing out the the faulty url. /lsapi/ is an old link from our previous web site but we overlooked it when creating important redirects to smooth the transition. Problem fixed. /lsapi/ will now be redirected to the correct page.
  7. intel352

    intel352 New Member

    So both PHP 4 and PHP 5 could be run in parallel using lsapi?

    Additionally, you said that lsapi functions similar to fastcgi, but faster, so does that mean it's performance is comparable to that of apache's mod_php, or is it faster? (I ask, because I know that FastCGI PHP doesn't seem to be *quite* as fast as mod_php, under apache)
  8. xing

    xing LiteSpeed Staff

    LSAPI PHP is much more scalable than mod_php not because it can excecute script faster but because it is much more resource efficient. Instead of having every single Apache process bind with mod_php even for requests that do not need it, LSAPI PHP creates a worker pool of php processes and thrink and expand as demand.
  9. mistwang

    mistwang LiteSpeed Staff

    And both FCGI PHP and LSAPI PHP with LiteSpeed is faster than Apache's mod_php. LSAPI PHP is the fastest. Apache's mod_fastcgi is not as fast as ours.
    Please checkout our benchmark page.
    Last edited: Oct 11, 2006
  10. dreamscape

    dreamscape Active Member

    I just wanted to add a quick note that I am running both PHP 4 and PHP 5.1 as LSAPI. Not only does it work great, but it was also incredibly easy to set up... Way easier than getting them running them in parallel in Apache (where one has to be CGI unless you run 2 Apache servers and proxy one to the other... yuk ;-) )
  11. Rob T

    Rob T Member

    Sorry to resurrect this old thread, but is there a good how-to anywhere on how to do this? I'd like to be running both php4 and php5 on our servers, and if this can be done easily with lsapi that would be great! However, I can't find any documentation on how to accomplish this in the forums or in the wiki. Ideas?
  12. mistwang

    mistwang LiteSpeed Staff

    You need to compile your own PHP5 LSAPI binary, then duplicate the existing configuration for PHP4, just make sure the script handler is for ".php5" suffix.
  13. Rob T

    Rob T Member

    I understand the concepts involved, I was wondering if there was more of a "step-by-step how-to" that existed anywhere that would speed up the learning curve a bit for someone who doesn't spend much time compiling software at the command line.

    If I end up diving in and giving it a shot, perhaps I'll write something up to make it easier for others in the future.
  14. mistwang

    mistwang LiteSpeed Staff

    Step by step wiki for compiling your own PHP binary is available

    You don't need to replace the old php binary, just name the php binary as "lsphp5" instead of "lsphp".

    Once you get the lsphp5 binary, just duplicate the existing server level php external app configuration and php script handler configuration, that's pretty easy.

    You are welcome to add your step by step guide to our wiki if you do write something. :)
  15. clarocque

    clarocque Member

    Did anyone end up doing a step by step for this?

    Did anyone end up doing a step by step for this?

    With my very limited experience with server stuff - I seem to get along up to the part about php.ini in the WIKI instructions. I sem to only have one ini file for php4???

    Anyone have any thoughts?

  16. mistwang

    mistwang LiteSpeed Staff

    You can creat a php.ini for php5, like something at lsws/php5/php.ini.

Share This Page