Using PHP with Plesk and LSWS

LiteSpeed Web Server requires PHP built with LSAPI, our optimized SAPI. Plesk has those binary packages built into their multi-version PHP rpms for CentOS, Ubuntu, and Debian.

The script will automatically do everything necessary for new LSWS installations; if you are setting up a new LSWS installation you may skip this guide without any problems.

If you have an existing LSWS installation and would like to convert LiteSpeed to support the Plesk PHP selector, or want to know how the Plesk PHP selector works with LiteSpeed, the following wiki will outline the necessary steps to set up or convert to the Plesk PHP selector for LiteSpeed.

CentOS/Ubuntu/Debian Users

Plesk versions older than 12.0 only support having a single version of PHP set up. Multi-PHP support started in Plesk 12.0. For CentOS/Ubuntu/Debian users, lsphp will be installed through plesk-php-cli packages.


If any PHP versions are not installed, you can install them through the command line:

plesk sbin autoinstaller --select-product-id plesk --select-release-current  --install-component phpx.x

PHP packages from the Plesk team are available on:

Plesk 12: CentOS 6, CentOS 7, and Ubuntu 12
Plesk 12.5: Ubuntu 12/14, Debian 7/8 and CentOS/RHEL 6, 7 operating systems.

The quickest and easiest way to set up/migrate LiteSpeed to support multiple PHP versions is to download and run the following script as root:


Notes: When setting up PHP for a domain, it should run as a FastCGI application instead of an FPM application. The current LiteSpeed PHP selector doesn't work with FPM applications.

You can also set these up manually by following the steps below, however this is unnecessary if you have already run the migration script.

With Plesk 12.0 and Plesk 12.5, you can install and use multiple PHP 5.x and 7.0 versions built by the Plesk team via the Plesk control panel without any additional third-party repositories or the need to build PHP from the source code yourself. The corresponding lsphp binary has been included in the plesk-phpxx-cli package. You will need to verify that these packages exist.

Verify Apache Ignore Modules

Check the LiteSpeed setting Apache Ignore modules located in LiteSpeed Web Admin Console → Server → General → Using Apache Configuration File → Ignore Apache Modules. Make sure the following modules are ignored: mod_php5,sapi_apache2,python,mod_php4,mod_php7,otherwise you may experience ““Forbidden: PHP engine is disable.” error, which is possibly caused by a php admin setting within those modules. However, mod_fcgid should NOT be ignored.

PHP mode: FastCGI Application

Plesk Admin → Domains → → PHP settings, when setting up PHP for a domain, PHP should be run as a FastCGI application instead of FPM application. Currently the LiteSpeed PHP selector doesn't work with FPM applications.

Verify your lsphp installations

Please refer to this plesk documentation to ensure Plesk multi-version PHPs have been installed. It can also be checked through the Plesk GUI: Add/Remove Components → Web hosting features → Different PHP interpreters versions. Install them if they are not yet installed.

The lsphp binary is included in the plesk-phpxx-cli package and the installation location should be:

find / | grep /bin/lsphp

For CentOS:

[root@plesk12-5 conf]# rpm -qa | grep cli | grep plesk-php

For Debian/Ubuntu:

root@plesk125debian7:~# dpkg -l | grep cli | grep plesk-php
ii  plesk-php52-cli                    5.2.17-debian7.0.15100614            amd64        Command-line interface for PHP
ii  plesk-php53-cli                    5.3.29-debian7.0.15102117            amd64        Command-line interface for PHP
ii  plesk-php54-cli                    5.4.45-debian7.0.16032517            amd64        Command-line interface for PHP
ii  plesk-php55-cli                    5.5.37-debian7.0.16063013            amd64        Command-line interface for PHP
ii  plesk-php56-cli                    5.6.23-debian7.0.16063012            amd64        Command-line interface for PHP
ii  plesk-php70-cli                    7.0.8-debian7.0.16063012             amd64        Command-line interface for PHP

If any plesk-php version is not installed, you can install it through the command line or Plesk GUI: Command line:

plesk sbin autoinstaller --select-product-id plesk --select-release-current  --install-component phpx.x
( x.x here can be 5.2, 5.3, 5.4, 5.5, 5.6, 7.0, any missing version). 

GUI: Navigate to the Plesk Installer interface and choose the PHP versions you need (Add/Remove Components → Web hosting features → Different PHP interpreters versions).

Configure lsphp external apps

Plesk versions supporting multi-php normally use php by OS as the system default PHP. Using php by OS Vendor is not recommended as this is usually a very old version of PHP and also because there is no equivalent lsphp provided by OS Vendors. You will have to select one of Plesk's lsphp versions. We recommend using lsphp 5.6 as your default PHP for LiteSpeed. You can also set this to other Plesk lsphp versions.

Your php by OS version can be checked with the following command:

/usr/bin/php -i | more

To setup PHP 5.6 as your default, you will need to copy the related binary from the Plesk lsphp directory.

cp /opt/plesk/php/5.6/bin/lsphp /usr/bin/lsphp
/usr/bin/lsphp -i | more
ln -sf /usr/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp5
service lsws restart

This will not change any LSWS external app lsphp5 settings but will change the command binary to the selected Plesk lsphp binary through the above symbolic link.

You will also need to create all other versions of lsphp this way. In the LSWS WebAdmin Console under Configuration → Server → External App click Add to create a new external app. In addition to the default lsphp5 application, create lsphp52/lsphp53/lsphp54/lsphp55/lsphp56, set socket addresses to be unique, usually the same as the app name, and set the Command field to the corresponding lsphp binary location. For example, /opt/plesk/php/x.x/bin/lsphp (where x.x should be 52,53,54,55,56 or 70). The rest of settings can be copied from the lsphp5 external app. The following is a screenshot of the settings for our example external app, lsphp56, the rest should be similar to this.

If you prefer using the command line instead of the GUI tool, you can edit the LSWS configuration file (usually /usr/local/lsws/conf/httpd_config.xml) by adding the configuration settings here to the <extProcessorList>… </extProcessorList> section.

Set handlers for different suffixes

Go to LSWS Web Admin Console → Configuration → Server → Script Handler. In addition to the default suffixes of php and php5, create the related suffixes php52, php53, php54, php55, and php56 with Handler Type set to LSAPI and Handler Name pointing to the newly created lsphp52, lsphp53, lsphp53, lsphp54, lsphp55, and lsphp56 External Apps accordingly. If your Plesk version supports PHP 7, you should also create a suffix php70 pointing to an lsphp70 external app.

If you prefer to make these changes through the command line, you can simply edit the httpd_config.xml file (usually /usr/local/lsws/conf/httpd_config.xml) and add the configuration settings here to your server side configuration file's <scriptHandlerList> </scriptHandlerList> section.

Gracefully restart LSWS to have these changes take effect.

403 Forbidden error

If any suffixes are not properly setup, for example, php56 is not set to use the lsphp56 handler, then accounts using PHP 5.6 may still work from Apache but LiteSpeed will return a 403 Forbidden error. This is because the related PHP handler has not yet been set for LiteSpeed Web Server.

If you are using a version of Plesk that is older than 12.0, you can only set up one version of PHP, which is most likely your OS's default version. OS default versions don't come with an LSPHP binary. You may have to choose a similar PHP version either from the LiteSpeed repository for CentOS users or build one from the source code for Ubuntu/Debian users.

CentOS Users

For CentOS 5, 6, and 7 users, we have a PHP repository with a wide range of PHP options. When LSWS is installed on a CentOS machine through our LiteSpeed Plesk Extension. Commonly used PHP packages will be installed automatically after choosing a PHP version. As a result, most CentOS users will not need to update or adjust their PHP after the initial installation.

If you prefer to have a matching PHP, you can check and install related lsphp versions yourself. The following section outlines the steps for manually installing lsphp for your Plesk server after installation. Installation through the LiteSpeed repository is recommended, though you can also use the Remi Repo or compile it yourself.

Installing through the LiteSpeed PHP Repository

Check which PHP version is being used by Plesk.

rpm -qa | grep php-

The result may differ between systems. For example, in CentOS6, it may return the default OS version of PHP 5.3.3.


Next you will need to install the corresponding version of lsphp, in this case it would be lsphp53.

First make sure that the LiteSpeed Repo is enabled, and then install lsphp with the following command:

yum install lsphp53 lsphp53-common lsphp53-mbstring lsphp53-mysql lsphp53-imap lsphp53-xml lsphp53-pdo lsphp53-gd

As noted above, most CentOS users will be adequately supported by the PHP build automatically installed when they installed LSWS through the Plesk Extension. Despite this, you may still want to add some of the special options available in the LiteSpeed Repository (such as opcode caching or alternate MySQL support packages).

For example,

 yum install lsphp53-pecl-apc


 yum install lsphp56-opcache

Please see the LiteSpeed Repository wiki entry for a full guide on installing PHP from our repository.

Installing PHP through Remi Repository

Les RPMs de Remi (Remi Repository) is an extensive, widely-used PHP repository, which also includes options to build PHP for LSWS (with LSAPI). Remi Repository contains a variety of uncommon PHP options and thus will be good for CentOS users whose applications need less common options.

Please see the LiteSpeed Repository wiki entry for a full guide on installing PHP for LSWS from the Remi Repo.

Debian Users

For Debian 8, please follow the instructions in the install php5-litespeed package from the LiteSpeed repository wiki to install the php5-litespeed binary from our repository.

Ubuntu Users

For Ubuntu 12 and 14, you need to compile PHP from the source code.

For CloudLinux Users

On a CloudLinux system, you have a choice of using either Plesk Multi-PHP or CloudLinux PHP Selector. When installing LSWS, the installation script will automatically configure PHP to use Plesk Multi-PHP and to use PHP version 5.6 by default.

The following default external apps are added to LSWS during the installation: lsphp5x and lsphp7x are for Plesk Multi-PHP. lsphp_selector is for CloudLinux PHP Selector.

lsphp_selector is configured to use the command: /usr/local/bin/lsphp

By default, we configure Plesk Multi-PHP 56 as default handler out of the box.

If you want to set CloudLinux PHP Selector as the handler instead, you will need to change .php and .php5 handlers from lsphp56 to lsphp_selector as the following, assuming that you have installed CloudLinux CageFS, enabled CageFS for all users, and PHP-Selector and lvemanager have also been installed and configured correctly.

If you have not installed and configured CloudLinux PHP Selector yet, you can take a look the following steps before you configure on LSWS as above.

Install CloudLinux PHP Selector

If php-selector was not installed, try the steps described in this installation guide.

yum groupinstall alt-php
yum update cagefs lvemanager

Set up native PHP for LiteSpeed

Almost all PHP versions can be handled by CloudLinux PHP Selector directly, however native PHP for LiteSpeed needs to be installed and configured manually.

When you install LiteSpeed through the plesk-litespeed extension, it will ask you for the default PHP version. You can determine the native PHP version by printing the PHP interpreter summary using the following command:

selectorctl --summary --show-native-version
4.4 e -
5.1 e -
5.2 e -
5.3 e -
5.4 e -
5.5 e -
5.6 e -
7.0 e -
native(5.3) e d

It lists all available PHP versions and, in this case, shows that 5.3 is the native and default version.

Choose 5.3 during the installation the extension will install a default list of PHP packages.

If the wrong version was picked for native mode during this installation, you can correct it manually using the following steps.

Check installed packages:

rpm -qa | grep php-

Install similar lsphp packages:

yum install lsphp53 lsphp53-common lsphp53-mbstring lsphp53-xml lsphp53-pdo lsphp53-ioncube-loader lsphp53-gd lsphp53-imap lsphp53-mysql

The PHP binary is installed to /usr/local/lsws/lsphp53/bin/lsphp

Copy the installed binary to /usr/local/bin/

cp /usr/local/lsws/lsphp53/bin/lsphp /usr/local/bin/lsphp

Force update the CageFS:

/usr/sbin/cagefsctl --force-update

Configure LiteSpeed to use PHP selector

Follow this guide to configure LiteSpeed to use php selector.

1. CloudLinux (''Admin Console -> Configuration -> Server -> General'') set to ''CageFS''
2. Enable SuExec: ''Server-> General -> PHP SuEXEC'' set to ''Yes''
3. LSPHP5 external app runs in SUEXEC non-daemon mode ONLY (''Run On Start Up'' set to ''Yes'' or ''No'')
4. In lsphp5 external app (''Admin Console -> Configuration -> Server -> External App -> lsphp5'')

Change the following:

command ⇒ $SERVER_ROOT/fcgi-bin/lsphp5


command ⇒ /usr/local/bin/lsphp

Config PHP version for users

PHP Selector provides an easy way to figure out which versions are available and selected for end users through the command line. You can get this information by running:

/usr/bin/cl-selector --summary php --user _USERNAME_
/usr/bin/cl-selector --current=php --user=USERNAME

Which will retrieve the PHP version set for a particular user and

/usr/bin/cl-selector --select=php --version=x.x(or native) --user=USERNAME

Which will set the desired current PHP version for particular user.

  • Admin
  • Last modified: 2018/09/17 19:33
  • by Michael Alegre