Actions

Help

Multiple PHPs

From OpenLiteSpeed Wiki

Revision as of 20:53, 25 July 2016 by Jackson (talk | contribs) (Install multiple PHPs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This wiki will address setting up multiple PHPs for one installation of OpenLiteSpeed. The wiki assumes you have our repository installed and enabled and that PHP is being downloaded from this repository. Multiple PHPs can just as easily be set up when PHP has been built from source, though. This wiki demonstrates installing different versions of PHP. You can also install the same version of PHP with different options. This wiki uses the WebAdmin console where possible.

Install multiple PHPs

yum groupinstall lsphp-all

The above command installs all available versions of PHP (5.2, 5.3, 5.4, 5.5, 5.6 and 7.0).

These PHP builds are installed to the following locations based on version number:

/usr/local/lsws/lsphp52/bin/lsphp
/usr/local/lsws/lsphp53/bin/lsphp
/usr/local/lsws/lsphp54/bin/lsphp
/usr/local/lsws/lsphp55/bin/lsphp
/usr/local/lsws/lsphp56/bin/lsphp
/usr/local/lsws/lsphp70/bin/lsphp

Define external applications for these PHPs

We will go through creating an external application for PHP 5.4. The default external applications can also be used with some modification.

Add an external application (in the WebAdmin console > Configuration > Server > External App > Add).

PHP Mult AddExtApp.png

Choose LSAPI for the application type.

PHP Mult LSAPIApp.png

Give the new external application an appropriate name, address, maximum number of connections, initial response timeout, and retry timeout.

PHP Mult Setting1.png

The most import setting is the Command setting. This tells the external application where to look for the PHP it will use. Direct it to one of your PHP installations.

PHP Mult Setting2.png

Set up script handlers

Script handlers will tell OpenLiteSpeed which scripts should go to which external application. There are many ways to configure this. You can, for example, stipulate different suffixes to be served by different external applications. We will be setting up a script handler at the virtual host level to tell OpenLiteSpeed that .php scripts in this virtual hosts should be served with our new lsphp54 external application. This will override any server-level script handler settings. Context-level setting can be used to override server- or virtual host-level settings.

Add a virtual host-level script handler (WebAdmin console > Configuration > Virtual Hosts > Example > Script Handlers > Add).

PHP Mult AddSH.png

Choose the suffix this script handler will handle, make the Handler Type LiteSpeed SAPI, and direct it toward the external application you just created.

PHP Mult SH.png

Graceful restart to save your changes.

PHP Mult Restart.png

OpenLiteSpeed will now serve .php scripts in the virtual host with PHP 5.4. You can repeat these processes for any other PHP builds you'd like to support.