Custom PHP Script Handler

J.T.

Well-Known Member
#1
Hi,

Following this thread: http://www.litespeedtech.com/support/forum/showthread.php?t=3995

I've now compiled:

1 x PHP 5.3.2 called "lsphpcerb"
1 x PHP 5.2.13 called "lsphpmage"

In /opt/lsws/ I can see those two folders, lsphpcerb and lsphpmage

drwxr-xr-x 7 root root 4096 Apr 28 16:48 lsphp5
drwxr-xr-x 7 root root 4096 May 19 14:59 lsphpcerb
drwxr-xr-x 7 root root 4096 May 19 15:38 lsphpmage
In fcgi-bin I have this:

-r-xr-xr-x 1 root root 3317 Feb 20 22:57 lsperld.fpl
-r-xr-xr-x 1 root root 2268816 Feb 20 22:57 lsphp
lrwxrwxrwx 1 root root 7 Feb 20 22:57 lsphp4 -> ./lsphp
lrwxrwxrwx 1 root root 11 May 19 14:59 lsphp5 -> lsphp-5.3.2
-rwxr-xr-x 1 root root 21737081 Apr 28 17:28 lsphp-5.2.13
-rwxr-xr-x 1 root root 21690644 Apr 28 17:18 lsphp-5.2.13.bak
-rwxr-xr-x 1 root root 26224733 May 19 14:59 lsphp-5.3.2
-r-xr-xr-x 1 root root 4666 May 19 14:50 RailsRunner.rb
-r-xr-xr-x 1 root root 1095 May 19 14:50 RailsRunner.rb.2.3
Now I set up a new VH. It is my intention to use the PHP 5.3.2 compilation called lsphpcerb for this.

Following the thread mentioned above, I was hoping this was a matter of setting the External App or Script Handler in the Virtual Host. But my custom named PHP compilations aren't showing.

When I click View/Edit on the VH and then External App I thought maybe I can edit the LSAPI App from something lsphp to lsphpcerb. Or under Script Handler edit php. Handler Type is LiteSpeed API and I had hoped and expected that now under Handler Name I would find my lsphpcerb. But I only get three options:

[Server Level]: lsphp5
[Server Level]: lsphp4
[VHost Level]: $VH_NAME_lsphp

So, what do I need to do to say "This VH needs its php files handled by lsphpcerb instead of lsphp5."

Any directions you can offer?
 

mistwang

LiteSpeed Staff
#2
create a external app called lsphpcerb, using lsphp-5.3.2 binary,
at vhost level add or change script handler for ".php" using the lsphpcerb application.
 

J.T.

Well-Known Member
#3
Thanks mistwang, appreciate your prompt responses.

create a external app called lsphpcerb
Under Server > External App or
Virtual Hosts > Xyz VH > External App?

I guess the latter as this is the only VH which will use this specific PHP setup.

using lsphp-5.3.2 binary
How exactly do I accomplish that? In Command? Or the socket Address?

at vhost level add or change script handler for ".php" using the lsphpcerb application.
That, I follow! Thanks.

I'd be ever so grateful if you could please elaborate on the above two points.
 

mistwang

LiteSpeed Staff
#4
If only used for that VHOST, just add it at vhost level.

In command, use path to lsphp-5.3.2 binary. Socket address should be unique, could be anything you want.
 

J.T.

Well-Known Member
#5
If only used for that VHOST, just add it at vhost level.
OK thanks.

In command, use path to lsphp-5.3.2 binary.
Think I finally get it now. Please correct me if I'm wrong on the following findings.

Key fact: You can compile PHP only once per version.

Example, possible:

- PHP 5.2.13 with Mailparse, plus;
- PHP 5.3.2 with Curl, plus;
- PHP 5.3.1 with SOAP

Example, not possible:

- PHP 5.3.2 with Curl and Mailparse, plus;
- PHP 5.3.2 with SOAP and GD

LSWS references each instance of a PHP compilation by its version number, not by an arbitrarily set name. (Would be nice if this changed...)

Building on the example, possible, you can have one VH with external app pointing to $SERVER_ROOT/fcgi-bin/lsphp-5.3.2 and one to $SERVER_ROOT/fcgi-bin/lsphp-5.2.13 - simply edit the standard LSAPI App External App and update the Name, Socket Address and Command.

My use case works now. Thanks for your help.

If the above finding is correct, I'd make it a feature request to be able to "label" a certain PHP compile set with a unique arbitrarily chosen reference so withing fast-cgi folder, the PHP binary is referenced with this label. That way, we can have multiple binary compilations of the same PHP version with different PHP extensions. On a busy web server with many sites/scripts, this make environment isolation much easier and greatly helps with upgrade paths etc.
 

NiteWave

Administrator
#6
Example, not possible:

- PHP 5.3.2 with Curl and Mailparse, plus;
- PHP 5.3.2 with SOAP and GD
it's possible, too.

steps:
1. assume you have defined external applications:
lsphp532_1 --> PHP 5.3.2 with Curl and Mailparse
lsphp532_2 --> PHP 5.3.2 with SOAP and GD

2. under admin console --> server or vhost --> Script Handler -->Add,
(for example,)
php52 -->lsphp532_1
php53 -->lsphp532_2
php52,php53 are suffixes.

thus, you've defined new php handlers:
application/x-httpd-php52
application/x-httpd-php53

3.you can choose different php handler in different folders.
in .htaccess,
to select "PHP 5.3.2 with Curl and Mailparse" to run .php, using
AddType application/x-httpd-php52 php
to select "PHP 5.3.2 with SOAP and GD" to run .php, using
AddType application/x-httpd-php53 php

and so on. you can verify this by access phpinfo() in that folder.
 
Top