[Resolved] One VH with Different PHP Version

Discussion in 'PHP' started by J.T., May 4, 2010.

  1. J.T.

    J.T. New Member

    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: May 7, 2010
  2. mistwang

    mistwang LiteSpeed Staff

    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.
  3. J.T.

    J.T. New Member

    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?
  4. mistwang

    mistwang LiteSpeed Staff

    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.
  5. J.T.

    J.T. New Member

    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: May 5, 2010
  6. mistwang

    mistwang LiteSpeed Staff

    It does not save resources, but provide some kind of isolation, one vhost does not affect another one.

Share This Page