Running PHP 4 and 5 in parallel

#1
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?
 

xing

LiteSpeed Staff
#2
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:

ts77

Well-Known Member
#3
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
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

http://www.litespeedtech.com/lsapi/

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

xing

LiteSpeed Staff
#6
Sasa,

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
Yes, you can use lsapi, it works in the similar way as FastCGI, just faster due to the optimization in protocol.
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)
 

xing

LiteSpeed Staff
#8
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.
 

mistwang

LiteSpeed Staff
#9
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:
#10
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
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?
 

mistwang

LiteSpeed Staff
#12
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
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.
 

mistwang

LiteSpeed Staff
#14
Step by step wiki for compiling your own PHP binary is available
http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed_wiki:php:lsapi

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

Chris
 
Top