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).
Choose LSAPI for the application type.
Give the new external application an appropriate name, address, maximum number of connections, initial response timeout, and retry timeout.
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.
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).
Choose the suffix this script handler will handle, make the Handler Type
LiteSpeed SAPI, and direct it toward the external application you just created.
Graceful restart to save your changes.
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.