Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
litespeed_wiki:plesk:php_guide [2018/09/17 19:30]
Michael Alegre [CentOS Users]
litespeed_wiki:plesk:php_guide [2019/09/19 19:31] (current)
Lisa Clarke Copyediting
Line 1: Line 1:
-====== Using PHP with Plesk and LSWS ======+====== Using PHP with Plesk and LiteSpeed Web Server ​======
  
-LiteSpeed Web Server ​requires PHP built with [[http://​www.litespeedtech.com/​products/​litespeed-sapi/​php|LSAPI]],​ our optimized SAPI. Plesk has those binary packages built into their multi-version ​PHP rpms for CentOS, Ubuntu, and Debian+LiteSpeed Web Server ​v5.4 and later auto-detects and loads all available PHP versionsThis means PHP should work with Plesk out-of-the-box after LSWS installation. There is no need to configure individual ​PHP external apps if you don't have any special requirements
  
-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 upgrade ​LSWS from an earlier version, there may be some existing internal apps and script handlers defined. There is no need to change ​any settings from LSWS Web Admin Console, as LSWS doesn'​t have its own native virtual hosts under Plesk. . If you need to change PHP versions or settings, you can simply do so through Plesk Admin (**Domain > PHP Settings**),​ the same way you would for Apache. LSWS reads Plesk Apache configuration files for virtual hosts and global settings
  
-If you have an existing LSWS installation ​and would like to convert LiteSpeed to support the Plesk PHP selectoror 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.+Use this wiki as a means of understanding how LiteSpeed Web Server ​and Plesk work together in terms of PHP. You shouldn'​t need to take these steps during installationbecause LSWS should //just work// ​with Plesk PHP right away.
  
 ====== CentOS/​Ubuntu/​Debian Users ====== ====== CentOS/​Ubuntu/​Debian Users ======
 +LiteSpeed Web Server requires LSPHP, which Plesk has built into its multi-version PHP rpms for CentOS, Ubuntu, and Debian. LSPHP is automatically installed when you install any version of Plesk Multi-PHP.
 +
 +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 when you install any PHP version.
  
-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. 
  
-  /​opt/​plesk/​php/​5.5/​bin/​lsphp 
   /​opt/​plesk/​php/​5.2/​bin/​lsphp   /​opt/​plesk/​php/​5.2/​bin/​lsphp
   /​opt/​plesk/​php/​5.3/​bin/​lsphp   /​opt/​plesk/​php/​5.3/​bin/​lsphp
-  /​opt/​plesk/​php/​5.6/​bin/​lsphp 
   /​opt/​plesk/​php/​5.4/​bin/​lsphp   /​opt/​plesk/​php/​5.4/​bin/​lsphp
 +  /​opt/​plesk/​php/​5.5/​bin/​lsphp
 +  /​opt/​plesk/​php/​5.6/​bin/​lsphp
   /​opt/​plesk/​php/​7.0/​bin/​lsphp   /​opt/​plesk/​php/​7.0/​bin/​lsphp
 +  /​opt/​plesk/​php/​7.1/​bin/​lsphp
 +  /​opt/​plesk/​php/​7.2/​bin/​lsphp
 +  /​opt/​plesk/​php/​7.3/​bin/​lsphp
  
   plesk-php52-cli   plesk-php52-cli
   plesk-php53-cli   plesk-php53-cli
   plesk-php54-cli   plesk-php54-cli
 +  plesk-php55-cli
 +  plesk-php56-cli
 +  plesk-php70-cli
 +  plesk-php71-cli
 +  plesk-php72-cli
 +  plesk-php73-cli
   plesk-php55-cli   plesk-php55-cli
   plesk-php56-cli   plesk-php56-cli
Line 33: Line 44:
   Plesk 12.5: Ubuntu 12/14, Debian 7/8 and CentOS/RHEL 6, 7 operating systems.   Plesk 12.5: Ubuntu 12/14, Debian 7/8 and CentOS/RHEL 6, 7 operating systems.
  
-===== Setting up Multiple PHPs for LSWS on Plesk >12.0 through the script ​=====  +==== Verify Apache Ignore Modules ​====
-   +
-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:+
  
-  wget http://​www.litespeedtech.com/​packages/plesk/migrate_litespeed_plesk_multi_php.sh +Check the LiteSpeed setting ​ [[https://​www.litespeedtech.com/​docs/webserver/config/​general#​apacheIgnoredModules|Apache Ignore Modules]] located in the LiteSpeed ​WebAdmin Console under **Server > General > Using Apache Configuration File**. Make sure the following modules are ignored: ​''​mod_php5,​sapi_apache2,​python,​mod_php4,​mod_php7''​, otherwise you may experience a "​Forbidden:​ PHP engine is disabled." error, which is possibly caused by a PHP admin setting within those modules
-  sh migrate_litespeed_plesk_multi_php.sh +
- +
-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. +
-  +
-===== Setting up Multiple PHPs for LSWS on Plesk >= 12.0 manually =====  +
- +
-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'' ​packageYou will need to verify that these packages exist. +
- +
-==== Verify Apache Ignore Modules ====+
  
-Check the LiteSpeed setting ​ [[https://​www.litespeedtech.com/​docs/​webserver/​config/​general#​apacheIgnoredModules|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.+NOTE: ''​mod_fcgid''​ should **NOT** be ignored.
  
-==== PHP mode: FastCGI Application ====+==== Must use FastCGI Application, not php-fpm ​====
  
-''​Plesk Admin -> Domains ​-> example.com ​-> 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.+In Plesk Admin, under **Domains > example.com > 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.
  
 {{ :​litespeed_wiki:​plesk:​plesk-php-fastcgi.png?​nolink&​700 |}} {{ :​litespeed_wiki:​plesk:​plesk-php-fastcgi.png?​nolink&​700 |}}
Line 60: Line 58:
 ==== Verify your lsphp installations ==== ==== Verify your lsphp installations ====
  
-Please refer to [[https://​kb.plesk.com/​en/​125146|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.+Please refer to [[https://​kb.plesk.com/​en/​125146|this ​Plesk documentation]] to ensure Plesk'​s ​multi-version PHPs have been installed. It can also be checked through the Plesk GUI under **Add/Remove Components > Web hosting features > Different PHP interpreter ​versions**. Install them if they are not yet installed.
  
 {{ :​litespeed_wiki:​plesk:​php_components.png?​nolink&​600 |}} {{ :​litespeed_wiki:​plesk:​php_components.png?​nolink&​600 |}}
  
-The lsphp binary is included in the plesk-phpxx-cli ​package and the installation location should be:+The LSPHP binary is included in the Pleas PHPxx CLI package and the installation location should be:
  
   find / | grep /bin/lsphp   find / | grep /bin/lsphp
Line 98: Line 96:
   ( x.x here can be 5.2, 5.3, 5.4, 5.5, 5.6, 7.0, any missing version). ​   ( x.x here can be 5.2, 5.3, 5.4, 5.5, 5.6, 7.0, any missing version). ​
 GUI: GUI:
-Navigate to the Plesk Installer interface and choose the PHP versions you need (''​Add/Remove Components ​-> Web hosting features ​-> Different PHP interpreters ​versions''​). +Navigate to the Plesk Installer interface and choose the PHP versions you need (**Add/Remove Components > Web hosting features > Different PHP interpreter ​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. +
- +
-{{ :​litespeed_wiki:​plesk:​plesk-lsphp56.png?​nolink&​500 |}} +
- +
-{{:​litespeed_wiki:​plesk:​plesk-multi-php-external-apps.png?​700|}} +
- +
-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 [[litespeed_wiki:​plesk:​php_guide:​multi-php-config|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  ​**[[litespeed_wiki:​plesk:​php_guide:​multi-php-handlers|configuration settings here]]** to your server side configuration file's ''<​scriptHandlerList>​ </​scriptHandlerList>''​ section. +
- +
-{{:​litespeed_wiki:​plesk:​plesk-multi-php-handlers.png?​700|}} +
- +
-Gracefully restart LSWS to have these changes take effect.+
  
 ==== 403 Forbidden error  ==== ==== 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 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 Apachebut LiteSpeed will return a ''​403 Forbidden''​ error. This is because the related PHP handler has not yet been set for LiteSpeed Web Server.
- +
-===== Installing LSPHP for LSWS for Plesk < 12.0 ===== +
- +
-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. +
- +
-  php-common-5.3.3-46.el6_6.x86_64 +
-  php-mbstring-5.3.3-46.el6_6.x86_64 +
-  php-cli-5.3.3-46.el6_6.x86_64 +
-  php-fpm-5.3.3-46.el6_6.x86_64 +
-  php-mysql-5.3.3-46.el6_6.x86_64 +
-  php-imap-5.3.3-46.el6_6.x86_64 +
-  php-xml-5.3.3-46.el6_6.x86_64 +
-  php-pdo-5.3.3-46.el6_6.x86_64 +
-  php-gd-5.3.3-46.el6_6.x86_64 +
-  php-5.3.3-46.el6_6.x86_64 +
- +
-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 +
-or  +
-   yum install lsphp56-opcache +
- +
-Please see the [[litespeed_wiki:​php:​rpm#​installing_php_from_the_litespeed_repository|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_wiki:​php:​rpm#​installing_php_from_remi_repo|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 [[litespeed_wiki:​php:​apt|install php5-litespeed package from the LiteSpeed repository wiki]] to install the php5-litespeed binary from our repository or the [[litespeed_wiki:​php:​lsapi|compile PHP from source code wiki]]. For Debian 7, you can [[litespeed_wiki:​php:​lsapi|compile PHP from source code]]. +
- +
-==== Ubuntu Users ==== +
- +
-For Ubuntu 12 and 14, you need to compile PHP from the source code.+
  
 ====== For CloudLinux Users ====== ====== For CloudLinux Users ======
Line 209: Line 119:
 {{ :​litespeed_wiki:​plesk:​plesk-installation-php-external-apps-php-handler-default.png?​700 |}} {{ :​litespeed_wiki:​plesk:​plesk-installation-php-external-apps-php-handler-default.png?​700 |}}
  
-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 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.
  
 {{ :​litespeed_wiki:​plesk:​plesk-installation-php-external-apps-php-handler-to-php-selector.png?​700 |}} {{ :​litespeed_wiki:​plesk:​plesk-installation-php-external-apps-php-handler-to-php-selector.png?​700 |}}
Line 215: Line 125:
 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. 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.
  
-===== How to install and configure CloudLinix PHP selector ===== 
- 
-==== Install CloudLinux PHP Selector ==== 
-If ''​php-selector''​ was not installed, try the steps described in [[http://​docs.cloudlinux.com/​index.html?​php_selector_installation.html|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- 
- 
-  alt-php-config-1-5.el6.noarch 
-  php-cli-5.3.3-46.el6_6.cloudlinux.x86_64 
-  php-devel-5.3.3-46.el6_6.cloudlinux.x86_64 
-  php-mbstring-5.3.3-46.el6_6.cloudlinux.x86_64 
-  php-5.3.3-46.el6_6.cloudlinux.x86_64 
-  php-xml-5.3.3-46.el6_6.cloudlinux.x86_64 
-  php-common-5.3.3-46.el6_6.cloudlinux.x86_64 
-  php-pdo-5.3.3-46.el6_6.cloudlinux.x86_64 
-  php-ioncube-loader-4.0.12-1.el6.cloudlinux.x86_64 
-  php-gd-5.3.3-46.el6_6.cloudlinux.x86_64 
-  php-imap-5.3.3-46.el6_6.cloudlinux.x86_64 
-  php-mysql-5.3.3-46.el6_6.cloudlinux.x86_64 
- 
-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 [[http://​docs.cloudlinux.com/​index.html?​litespeed_support.html|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 ​ 
-  
-to: 
-  
-  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:30
  • by Michael Alegre