LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > PHP > Custom PHP Script Handler

Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2010, 09:28 AM
J.T. J.T. is offline
Member
 
Join Date: Apr 2010
Posts: 47
Question Custom PHP Script Handler

Hi,

Following this thread: http://www.litespeedtech.com/support...ead.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

Quote:
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:

Quote:
-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?
Reply With Quote
  #2  
Old 05-19-2010, 04:29 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
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.
Reply With Quote
  #3  
Old 05-20-2010, 12:53 AM
J.T. J.T. is offline
Member
 
Join Date: Apr 2010
Posts: 47
Thanks mistwang, appreciate your prompt responses.

Quote:
Originally Posted by mistwang View Post
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.

Quote:
Originally Posted by mistwang View Post
using lsphp-5.3.2 binary
How exactly do I accomplish that? In Command? Or the socket Address?

Quote:
Originally Posted by mistwang View Post
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.
Reply With Quote
  #4  
Old 05-20-2010, 08:04 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
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.
Reply With Quote
  #5  
Old 06-01-2010, 12:14 AM
J.T. J.T. is offline
Member
 
Join Date: Apr 2010
Posts: 47
Quote:
Originally Posted by mistwang View Post
If only used for that VHOST, just add it at vhost level.
OK thanks.

Quote:
Originally Posted by mistwang View Post
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.
Reply With Quote
  #6  
Old 06-01-2010, 01:53 AM
NiteWave NiteWave is online now
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,226
Quote:
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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:22 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.