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:php:detached_mode [2018/09/20 16:20]
Jackson Zhang
litespeed_wiki:php:detached_mode [2020/02/26 22:53] (current)
Lucas Rolff Bump to PHP 7.4
Line 2: Line 2:
  
 ===== What is PHP Detached Mode? ===== ===== What is PHP Detached Mode? =====
-PHP Detached Mode is a big feature available in LSWS 5.3 and later. ​+PHP Detached Mode is a big feature available in LSWS 5.3 and later. OpenLiteSpeed supports PHP detached mode starting from 1.5.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.  ​
Line 23: Line 23:
  
 ==== For a User ==== ==== For a User ====
-To restart detached PHP processes for the account (vhost) level, you can touch a ''​.lsphp_restart.txt''​ file under the user's home directory:+To restart detached PHP processes for the account (vhost) level, you can touch a ''​.lsphp_restart.txt''​ file under the user's home directory, for example ''/​home/​USER1/''​ on a cPanel/WHM server:
  
-  touch <​user_home_dir>​/​.lsphp_restart.txt+  touch /home/USER1/​.lsphp_restart.txt
   ​   ​
-The user can also restart detached PHP processes from the 'Advanced' ​page of the [[litespeed_wiki:​cpanel:​cpanel-plugin|LiteSpeed Web Cache Manager cPanel plugin]], accessible from within ​their cPanel dashboard.+Once ''​.lsphp_restart.txt''​ is created, the user's PHP will be restarted when next request comes in.  ​The file ''​.lsphp_restart.txt''​ won't be removed. LSWS will check the timestamp of the file to decide if the user's detached PHP needs to be restarted or not. You can manually remove it if you want to but it's not necessary. Every time you want to restart that user's detached PHP, you can just touch the file again, whether it already exists or not, in order to refresh the timestamp.  
 + 
 +To maintain CloudLinux mod_lsapi CRIU feature compatibility,​ the server will restart PHP if it finds a ''​mod_lsapi_reset_me''​ file as well.  
 +   
 +  touch <​user_home_dir>/​mod_lsapi_reset_me 
 + 
 +The user may also restart detached PHP processes from the **Advanced** page of the [[litespeed_wiki:​cpanel:​cpanel-plugin|LiteSpeed Web Cache Manager cPanel plugin]], accessible from within ​the cPanel dashboard.
  
 ==== For the Server ==== ==== For the Server ====
Line 43: Line 49:
  
 ===== PHP Processes Won't Run Forever ===== ===== PHP Processes Won't Run Forever =====
-PHP Detached Mode doesn'​t mean that PHP will run forever. It will still follow the [[https://​www.litespeedtech.com/​docs/​webserver/​config/​extapps/​lsapi#​extMaxIdleTime |Max Idle Time]] setting. If you want to make PHP live longer, just increase **Max Idle Time**. ​+PHP Detached Mode doesn'​t mean that PHP will run forever. It will still follow the [[https://​www.litespeedtech.com/​docs/​webserver/​config/​extapps/​lsapi#​extMaxIdleTime |Max Idle Time]] setting. If you want to make PHP live longer, just increase **Max Idle Time**.  Never set it to ''​-1''​ to indicate "​unlimited"​ since, in process group mode, values under ''​30''​ will be automatically converted to the default of 30 seconds. If you want PHP to be running longer, try to enter a large number, such as ''​3600''​.
  
 +===== When Changes Become Effective =====
 +Changes to Detached Mode will be effective when the app restarts.
 +
 +Remember, the Detached Mode app isn't started when the server starts up. It only starts when there is traffic hitting the external app. It will be started on demand, and remain running even if LSWS restarts.
 +
 +The same for the restart. Only if an external application is about to serve a request, will it be checked and restarted if needed.
 ===== PHP Auto Configuration for Different Control Panels ===== ===== PHP Auto Configuration for Different Control Panels =====
 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. 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.
Line 54: Line 66:
 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. ​ 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. ​
  
-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. ​+Currently, LSWS auto-detects apps and handlers up to PHP 7.4. 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. 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.
Line 73: Line 85:
  
  
-===== ea-phpxx and alt-phpxx are different handlers on LSWS 5.3 while same on LSWS 5.2.x and below ===== +===== Troubleshooting ​=====
- +
-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. +  * [[litespeed_wiki:​php:​detached_mode:​handlers | Managing ​ea-phpxx and alt-phpxx differences between LSWS v5.3 and previous versions]]
-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: 2018/09/20 16:20
  • by Jackson Zhang