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
Next revision Both sides next revision
litespeed_wiki:php:detached_mode [2018/09/13 15:27]
Lisa Clarke [How to enable PHP Detached Mode?] Proofreading
litespeed_wiki:php:detached_mode [2018/09/20 16:20]
Jackson Zhang
Line 6: Line 6:
 In previous versions (LSWS 5.2.x and below), all PHP processes were attached to LiteSpeed Web Server processes. As such, when LiteSpeed Web Server restarted, so would the PHP processes. In PHP Detached Mode, the PHP processes will continue running independently,​ even when LiteSpeed Web Server restarts.  ​ In previous versions (LSWS 5.2.x and below), all PHP processes were attached to LiteSpeed Web Server processes. As such, when LiteSpeed Web Server restarted, so would the PHP processes. In PHP Detached Mode, the PHP processes will continue running independently,​ even when LiteSpeed Web Server restarts.  ​
  
-When you run in PHP Process Group Mode, PHP process groups are still started by the ''​litespeed''​ process. When the first request for a specific PHP process group comes in, if PHP is not running it, it will be started by LiteSpeed. ''​pstree''​ will show that PHP process is child of the ''​litespeed''​ process. That's normal. What's new is that, as of 5.3, once the ''​litespeed''​ process exits, the PHP process won't quit. It will become independent.+When you run in PHP ProcessGroup ​Mode, PHP process groups are still started by the ''​litespeed''​ process. When the first request for a specific PHP process group comes in, if PHP is not running it, it will be started by LiteSpeed. ''​pstree''​ will show that PHP process is child of the ''​litespeed''​ process. That's normal. What's new is that, as of 5.3, once the ''​litespeed''​ process exits, the PHP process won't quit. It will become independent.
  
 ===== Benefit of PHP Detached Mode ===== ===== Benefit of PHP Detached Mode =====
Line 16: Line 16:
 If you are using a control panel, LSWS 5.3 will enable PHP detached mode automatically. ​ If you are using a control panel, LSWS 5.3 will enable PHP detached mode automatically. ​
  
-If you are using LSWS 5.3 Native Mode, and explicitly configured an external application for each virtual host, you will need to set **Run on Startup** to ''​PHP Detached Mode''​.  ​+If you are using LSWS 5.3 (native), and explicitly configured an external application for each virtual host, you will need to set **Run on Startup** to ''​PHP Detached Mode''​.  ​
 ===== Restart Detached PHP Processes ===== ===== Restart Detached PHP Processes =====
 In the past, if there were any ''​php.ini''​ changes, you would probably want to restart LSWS to apply the changes(since LSWS will restart PHP processes). ​ In the past, if there were any ''​php.ini''​ changes, you would probably want to restart LSWS to apply the changes(since LSWS will restart PHP processes). ​
Line 46: Line 46:
  
 ===== PHP Auto Configuration for Different Control Panels ===== ===== PHP Auto Configuration for Different Control Panels =====
-In previous ​version lower than LSWS 5.2.x, ​there is a "​External App" section to setup PHP external apps and a "​Script Hander"​ section to setup PHP handlers. ​+In previous ​versions of LSWS (5.2.x and earlier), external apps and PHP handlers ​are set up via the **External App** and **Script Hander** sections, respectively.
  
 {{ :​litespeed_wiki:​php:​lsws5.3-php-detached-mode-php-externalapp.png?​800 |}} {{ :​litespeed_wiki:​php:​lsws5.3-php-detached-mode-php-externalapp.png?​800 |}}
  
-On LSWS 5.3,  PHP external app and PHP script handler ​configurations are not required ​anymore ​and they will be autoconfigured by the web server. If you run upgrade from 5.2.x or previous ​version, external apps settings will be carried over. Actually ​you can delete all PHP external apps and PHP handlers and LSWS will still be working ​fine. If you install a new fresh LSWS 5.3 installation,​ most likely you won't see any PHP external apps and PHP handlers defined there anymore. If you see such, don't worry and it is normal for LSWS 5.3. If you still want to define external apps manually, it is ok, and LSWS will honor the settings which actually override the LSWS 5.3 built-in external apps definition. ​+On LSWS v5.3 and abovethese configurations are no longer ​required. External apps and script handlers ​will be autoconfigured by the web server. If you upgrade ​to v5.3 from an earlier ​version, ​the external apps settings will be carried over. (However, ​you could delete all PHP external apps and PHP handlers and LSWS would still work fine.)
  
 +If you install a new fresh LSWS 5.3 installation,​ you probably won't see any PHP external apps or PHP handlers defined there. Don't worry. This is normal. If you still want to define external apps manually, you can do so. LSWS will honor these settings, and they will override the built-in external apps definition. ​
  
-How to configure PHP setting then if there are no external apps defined there anymore? ​While a new "PHP" ​tab has been created ​in LSWS Web Admin Console and you can set configuration there to detached ​PHP.+Currently, LSWS auto-detects apps and handlers up to PHP 7.3. Two handlers: ''​application/​x-httpd-ea-php71''​ and ''​application/​x-httpd-alt-php71''​ now point to separate handlers, where prior to 5.3, both pointed to the lsphp71 handler configuration.  
 + 
 +So, how do you configure PHP settings ​if there are no external apps defined there anymore? ​See the new **PHP** tab in the Web Admin console to adjust the configuration
 + 
 +Configurations set under the **PHP** tab or in the ''<​phpConfig>''​ section, serve as the default for auto-detected PHP handlers, so the memory limit set there will apply to all detected ​PHP handlers. An explicitly configured PHP handler will still use its own configuration.
    
 {{ :​litespeed_wiki:​php:​lsws5.3-php-detached-mode-php-tab.png?​800 |}} {{ :​litespeed_wiki:​php:​lsws5.3-php-detached-mode-php-tab.png?​800 |}}
Line 66: Line 71:
 Change the PHP binary path: Change the PHP binary path:
 {{ :​litespeed_wiki:​php:​lsws53-php-override2.png?​800 |}} {{ :​litespeed_wiki:​php:​lsws53-php-override2.png?​800 |}}
 +
 +
 +===== ea-phpxx and alt-phpxx are different handlers on LSWS 5.3 while same on LSWS 5.2.x and below =====
 +
 +LSWS 5.3 speically adds alt-phpxx(CloudLinux PHP selector) handlers'​ suppport for cPanel and CloudLinux system hence alt-phpxx are different than ea-phpxx. On previous version of LSWS 5.2.x and below, there is no separate handler between alt-phpxx and ea-phpxx
 +and both of them use ea-phpxx handlers. ​
 +
 +The above feature will support latest cPanel multi-PHP manager more friendly since either alt-phpxx or ea-phpxx can be selected for a domain, instead of just ea-phpxx only. Then cPanel will add the following to .htaccess depending on which php was selected. LSWS 5.3 will use alt-phpxx or ea-phpxx according to user's choice. ​ On LSWS 5.2.x and below version, LSWS will only set ea-phpxx no matter alt-phpxx or ea-phpxx selected.
 +
 +  AddType application/​x-httpd-alt-php70 .php .php7 .phtml
 +or 
 +  AddType application/​x-httpd-ea-php70 .php .php7 .phtml
 +
 +
 +On LSWS 5.2.x, if you set all lsphpxx binary to use alt-phpxx for all handlers and set some per directory php as the following by using ea-phpxx in .htaccess. ​
 +
 +  AddType application/​x-httpd-ea-php54 .php .php7 .phtml
 +or 
 +  <​FilesMatch "​.(php4|php5|php3|php2|php|phtml)$">​
 +  SetHandler application/​x-httpd-ea-php54
 +  </​FilesMatch>​
 +
 +It works with LSWS 5.2.x but doesn'​t work with LSWS 5.3. Why?
 +
 +LSWS 5.3 treats ea-phpXX handler and alt-phpXX handler separately. ​
 +If the server only have ea-php70 installed and other ea-phpXX handler is not available, then
 +
 +  SetHandler application/​x-httpd-ea-php54
 +or
 +  SetHandler application/​x-httpd-ea-php55
 +
 +will fail.
 +
 +5.2.x treat ea-phpXX and alt-phpXX handler the same and handled by lsphpXX handler which pointing to alt-php binary.
 +
 +How to fix it?
 +
 +==== Method1: You should use right Handler for LSWS 5.3 now ====
 +
 +In .htaccess, you should change:
 +  SetHandler application/​x-httpd-ea-php54
 +to 
 +  SetHandler application/​x-httpd-alt-php54
 +  ​
 +and you should use the right one moving forward. But it seems a little time consuming to change all handler settings in all .htaccess for 5.2.x to 5.3 migration. There is another way as the following:
 +
 +==== Method2: Make LSWS 5.3 behaves as 5.2.x ====
 +
 +Instead of scanning .htaccess to fix wrong handler configuration,​ it is possible to make 5.3 behave the same as 5.2.x.
 +Please update the name of lsphpXX external app from lsphpXX to ea-phpXX, the executable path is still pointing to alt-php binary. this way, ea-phpXX, alt-phpXX, and lsphpXX are all handled by alt-php handlers.
 +
  • Admin
  • Last modified: 2020/02/26 22:53
  • by Lucas Rolff