[Resolved] One VH with Different PHP Version

J.T.

Well-Known Member
#1
Hi,

I'm looking at ways to accomplish the following.

For one bit of PHP software I'd like to run 5.2.13. For another script I'd like to go with 5.3.latest

Right now they are both on the same domain, hence on the same virtualhost. I can split them by virtualhost if this makes it easier.

I just went through the server settings, as well as the VH settings but can't figure this out.

After compiling multiple PHP versions (so far I've just done 5.2.13) how do we specify which virtualhost uses which PHP version? Taking that further, how do we tell which directory is to be processed by which PHP version?

Hope you can point me in the right direction, thanks!
 
Last edited by a moderator:

mistwang

LiteSpeed Staff
#2
Are you using LSWS with Apache httpd.conf or just configure everything natively from LSWS web console?
Basically, you assign PHP version with MIME type
application/x-httpd-php4 , application/x-httpd-php5 , etc.
Those MIME types are added by LSWS with you define a script handler for suffix php4 or php5. If you add a script handler for suffix "php53", then MIME type
application/x-httpd-php53 will be added.
Then you can change PHP version with Apache style configuration like

AddType application/x-httpd-php53 php

to use PHP 5.3 for file with suffix ".php".
It can be done in .htaccess or in LSWS configuration.
 

J.T.

Well-Known Member
#3
It's a clean LSWS install, configured through admin console so no Apache relation any more.

I guess the sequence then is as follows.

1. Compile PHP 5.2.13 for example as LSPHP5213 with path /opt/lsws/lsphp5213
2. Compile PHP 5.3.2 for example as LSPHP532 with path /opt/lsws/lsphp532
3. Under Configuration > Virtual Hosts I edit VH "A", add a Script Handler, handler type Litespeed API and then the new drop-down will show lsphp5213 and lsphp532, pick one of those and then in suffixes, I just put .php so I don't have to rename all extensions.
4. Repeat 3 for VH "B"

Doing that per VH overrides the Server Wide script handler settings, which defaults to lsphp5.

Is that correct? I don't want to change all the .php to .php53 so I guess the above does it VH-wide, correct?
 

mistwang

LiteSpeed Staff
#4
Yes, if you want to change PHP version VH-wide, you can do that.
If you only change it for certain PHP script, you need to play with the MIME types.
 

J.T.

Well-Known Member
#5
That's fantastic, thanks.

Do you think we can actually save resources/CPU cycles etc. this way?

Say VH "A" is for a domain that is used 50% of all requests and it doesn't need any extra PHP extensions, and then VH "B" gets the other 50% of requests and does need a fair number of extensions. By compiling "dedicated" PHP environments for each, do we add overhead (two sets of PHP running) or actually save resources (half the requests aren't weighed down by unneeded extensions)?
 
Last edited:
Top