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:lsapi-environment-variables [2018/09/14 16:08]
Michael Alegre [LSAPI_MAX_PROCESS_TIME]
litespeed_wiki:php:lsapi-environment-variables [2018/09/19 16:15] (current)
Michael Alegre [LSAPI_ACCEPT_NOTIFY]
Line 1: Line 1:
-====== Directives + Environment Variables ​for PHP LSAPI ======+====== ​PHP LSAPI Directives + Environment Variables ======
  
 Much of your LSPHP settings(Environment Variables) are controlled by your external application settings (WebAdmin console > Configuration > External App), while "​LSPHP_ProcessGroup on" and "​LSPHP_Workers xx" are directives to be used within apache configuration in control panel environment. These settings and directives are explained in the LiteSpeed Web Server documentation. Much of your LSPHP settings(Environment Variables) are controlled by your external application settings (WebAdmin console > Configuration > External App), while "​LSPHP_ProcessGroup on" and "​LSPHP_Workers xx" are directives to be used within apache configuration in control panel environment. These settings and directives are explained in the LiteSpeed Web Server documentation.
Line 5: Line 5:
 LSAPI setups can be further configured, however, using the directives and environment variables listed below. LSAPI setups can be further configured, however, using the directives and environment variables listed below.
  
-===== LiteSpeed-Specific Directives ​used in Apache conf in control panel Environment===== +===== LiteSpeed-Specific Directives ===== 
-**Note:** The following directives are LiteSpeed-specific directives to be used in apache ​configuration ​file which LSWS read in control panel environment. They are to enable PHP ProcessGroup mode in control panel environment(When LSWS native ​mode, no need such directives ​and processGroup will be configured through ​ext app.Please check [[litespeed_wiki:​php:​which_php_setup_am_i_using#​suexec_processgroup_mode|here]] for setup details). Apache will not understand ​them and may crash if they are not wrapped in **<​IfModule>​**, as in the following example:+ 
 +**Note:** The following directives are LiteSpeed-specific directives to be used in Apache ​configuration ​files read by LiteSpeed Web Server ​in control panel environments. They are used to enable PHP ProcessGroup mode in control panel environments ​(When using LiteSpeed Web Server (native)there is no need to add these directives ​as processGroup will be configured through ​an external application. Please check [[litespeed_wiki:​php:​which_php_setup_am_i_using#​suexec_processgroup_mode|here]] for setup details). ​ 
 + 
 +Apache will not understand ​these directives ​and may crash if they are not wrapped in ''​<​IfModule ​LiteSpeed>''​ tags, as in the following example:
  
   <​IfModule LiteSpeed>​   <​IfModule LiteSpeed>​
Line 15: Line 18:
 ==== LSPHP_Workers ====  ==== LSPHP_Workers ====
  
-**LSPHP_Workers** controls the maximum number of worker/​child processes per account in shared hosting. This directive can be used at the server ​level or virtual host level.+The ''​LSPHP_Workers''​ directive ​controls the maximum number of worker/​child processes per account in shared hosting ​environment. This directive can be used at the server or virtual host level.
  
 ==== LSPHP_ProcessGroup ==== ==== LSPHP_ProcessGroup ====
  
-**LSPHP_ProcessGroup** turns ProcessGroup mode "on" ​and "off" ​when using Apache ​configs. This directive can be used at the server ​level or virtual host level.+The ''​LSPHP_ProcessGroup''​ directive ​turns ProcessGroup mode ''​on'' ​and ''​off'' ​when using Apache ​configuration files. This directive can be used at the server or virtual host level.
  
 ==== LSPHP_MaxWaitQ ==== ==== LSPHP_MaxWaitQ ====
  
-**LSPHP_MaxWaitQ** sets maximum number of processes that can be in the PHP external application wait queue. When this limit is reached, new requests will return a 508 "​Resource Limit Reached"​ error. This directive can be used at the server ​level or virtual host level.+The ''​LSPHP_MaxWaitQ''​ directive ​sets the maximum number of processes that can be in the PHP external application wait queue. When this limit is reached, new requests will return a 508 "​Resource Limit Reached"​ error. This directive can be used at the server or virtual host level.
  
  
-===== Environment Variables ​configurable at LSPHP external apps =====+===== LSPHP External App Environment Variables =====
  
 The following environment variables are supposed to be used at LSPHP external app configurations,​ not to be used in apache configuration. ​ The following environment variables are supposed to be used at LSPHP external app configurations,​ not to be used in apache configuration. ​
 ==== LSAPI_CHILDREN or PHP_LSAPI_CHILDREN ==== ==== LSAPI_CHILDREN or PHP_LSAPI_CHILDREN ====
  
-(default: 35)+Default Value''​35''​
  
-PHP LSAPI allows a variety of setups. Two of these setups, Worker and ProcessGroup can be set using this environment variable. (Note: In previous versions of this documentation,​ Worker was referred to as "​server managed mode" and ProcessGroup referred to as "self managed mode"​.)+PHP LSAPI allows a variety of process modes. Two of these modes, Worker and ProcessGroupcan be set using this environment variable. (Note: In previous versions of this documentation,​ Worker was referred to as "​server managed mode" and ProcessGroup referred to as "self managed mode"​.)
  
-Setting ​**LSAPI_CHILDREN** to <​nowiki><​=</​nowiki> ​1 puts LSWS in Worker mode. In Worker mode, LiteSpeed Web Server dynamically spawns new PHP processes to meet demand and kills finished processes. In this mode, an external application'​s Instances setting ​(WebAdmin console > Configuration > External App > your external application) ​should match the Max Connections setting ​(WebAdmin console > Configuration > External App > your external application).+Setting ​''​LSAPI_CHILDREN'' ​to ''​1'' ​puts LSWS in Worker mode. In Worker mode, LiteSpeed Web Server dynamically spawns new PHP processes to meet demand and kills finished processes. In this mode, an external application'​s Instances setting ​under **Configuration > External App > your_external_application** ​should match the **Max Connections** setting ​in the same location.
  
-Setting ​**LSAPI_CHILDREN** to >1 puts LSWS in ProcessGroup mode. In ProcessGroup mode, the web server will start one constantly-running PHP parent process, and this process will fork child PHP processes (as opposed to spawning new processes) to meet demand. ProcessGroup is generally preferred because all PHP processes can then share one memory block for opcode caching. In ProcessGroup mode, Instances should be set to 1, while **LSAPI_CHILDREN** should be set to match the value of Max Connections. Usually, there is no need to set **LSAPI_CHILDREN** over 100. +Setting ​''​LSAPI_CHILDREN'' ​to ''​1'' ​puts LSWS in ProcessGroup mode. In ProcessGroup mode, the web server will start one constantly-running PHP parent process. This process will then fork child PHP processes (as opposed to spawning new processes) to meet demand. ProcessGroup ​mode is generally preferred because all PHP processes can then share one memory block for opcode caching. In ProcessGroup mode, **Instances** should be set to ''​1''​, while ''​LSAPI_CHILDREN'' ​should be set to match the value of **Max Connections**.
- +
-**Note:** When using suEXEC set in Apache configs, LSWS's default **LSAPI_CHILDREN** changes to 0. Thus, the default Apache suEXEC is Worker mode. ProcessGroup can be enabled when using Apache configs by using the directive **LSPHP_ProcessGroup** listed above.+
  
 ==== LSAPI_AVOID_FORK ==== ==== LSAPI_AVOID_FORK ====
  
-(default: 0)+Default Value''​0''​
  
-**LSAPI_AVOID_FORK** specifies whether the internal process manager in ProcessGroup mode should try to avoid forking new child processes.+The ''​LSAPI_AVOID_FORK''​ environment variable ​specifies whether the internal process manager in ProcessGroup mode should try to avoid forking new child processes.
  
-When set to 0, the internal process manager will not try to avoid forking new processes. To save system resources, it will stop processes when they finish and only start child processes when they are needed. This is often preferred in shared hosting.+When set to ''​0''​, the internal process manager will not try to avoid forking new processes. To save system resources, it will stop processes when they finish and only start child processes when they are needed. This is often preferred in shared hosting.
  
-When set to 1, the internal process manager will try to avoid frequently stopping and starting child processes. This might be preferred in a dedicated hosting environment because it may be faster to recycle existing processes, even if it means running ​processes when they are unused ​sometimes.+When set to ''​1''​, the internal process manager will try to avoid frequently stopping and starting child processes. This might be preferred in a dedicated hosting environment because it may be faster to recycle existing processes, even if it means sometimes ​running unused ​processes.
  
 ==== LSAPI_EXTRA_CHILDREN ==== ==== LSAPI_EXTRA_CHILDREN ====
  
-(default1/3 of **LSAPI_CHILDREN** or 0) +Default Value:\\ 
- +If ''​LSAPI_AVOID_FORK'' ​is set to ''​0'':​ ''​LSAPI_CHILDREN/3''​\\ 
-In ProcessGroup mode, **LSAPI_EXTRA_CHILDREN** controls the maximum number of extra child processes that can be started when existing child processes are malfunctioning. The total number of child processes will be reduced to the level set in **LSAPI_CHILDREN** as soon as service is back to normal. When **LSAPI_AVOID_FORK** is set to 0, the default value of **LSAPI_EXTRA_CHILDREN** is 1/3 of **LSAPI_CHIDLREN**. When **LSAPI_AVOID_FORK** is set to 1, the default value is 0.+If ''​LSAPI_AVOID_FORK'' ​is set to ''​1'':​ ''​0''​
  
 +In ProcessGroup mode, the ''​LSAPI_EXTRA_CHILDREN''​ environment variable controls the maximum number of extra child processes that can be started when existing child processes are malfunctioning. The total number of child processes will be reduced to the level set in ''​LSAPI_CHILDREN''​ as soon as service is back to normal.
 ==== LSAPI_MAX_REQS or PHP_LSAPI_MAX_REQUESTS ==== ==== LSAPI_MAX_REQS or PHP_LSAPI_MAX_REQUESTS ====
  
-(default: 10000)+Default Value''​10000''​
  
-In ProcessGroup mode, this controls ​how many requests each child process will handle before ​it exits automatically. Several PHP functions have been identified as having memory leaks. This parameter can help reduce memory usage by leaky PHP functions.+In ProcessGroup mode, this environment variable ​controls ​the number of requests each child process will handle before ​exiting ​automatically. Several PHP functions have been identified as having memory leaks. This parameter can help reduce memory usage by leaky PHP functions.
  
 ==== LSAPI_MAX_IDLE ==== ==== LSAPI_MAX_IDLE ====
  
-(default: 300 seconds)+Default Value''​300'' ​seconds
  
-In ProcessGroup mode, **LSAPI_MAX_IDLE** controls how long an idle child process will wait for a new request before it exits. This option helps release system resources taken by idle processes.+In ProcessGroup mode, ''​LSAPI_MAX_IDLE'' ​controls how long an idle child process will wait for a new request before it exits. This option helps release system resources taken by idle processes.
  
 ==== LSAPI_MAX_IDLE_CHILDREN ==== ==== LSAPI_MAX_IDLE_CHILDREN ====
  
-(default1/3 of **LSAPI_CHILDREN** or **LSAPI_CHILDREN**)+Default Value:\\ 
 +If ''​LSAPI_AVOID_FORK''​ is set to ''​0'':​ ''​LSAPI_CHILDREN/3''​\\ 
 +If ''​LSAPI_AVOID_FORK''​ is set to ''​1'':​ ''​LSAPI_CHILDREN''​
  
-In ProcessGroup mode, **LSAPI_MAX_IDLE_CHILDREN** controls how many idle child processes are allowed. Extra idle child processes will be killed by the parent process immediately. When **LSAPI_AVOID_FORK** is set to 0, the default value of **LSAPI_MAX_IDLE_CHILDREN** is 1/3 of **LSAPI_CHIDLREN**. When **LSAPI_AVOID_FORK** is set to 1, the default value of **LSAPI_MAX_IDLE_CHILDREN** is the same as the value of **LSAPI_CHILDREN**. +In ProcessGroup mode, ''​LSAPI_MAX_IDLE_CHILDREN'' ​controls how many idle child processes are allowed. Extra idle child processes will be killed by the parent process immediately.
- +
-==== extMaxIdleTime ==== +
-extMaxIdleTime in LSWS server configuration is the total time that an idle PHP process group (no request is being processed), wait for new request before exiting. the process group will be gone after timeout.+
  
 ==== LSAPI_MAX_PROCESS_TIME ==== ==== LSAPI_MAX_PROCESS_TIME ====
  
-(default: 300 seconds+Default Value''​300'' ​seconds
- +
-LSAPI_MAX_PROCESS_TIME is the total time that a PHP process can spend in processing a request. It only effective in ProcessGroup or Daemon mode. The parent process will kill the child process spending more time than the threshold.+
  
-In ProcessGroup mode, **LSAPI_MAX_PROCESS_TIME** controls the maximum processing ​time allowed when processing ​request. If a child process can not finish ​processing a request in the given time period, it will be killed by the parent process. This option can help get rid of dead or runaway ​child processes.+The ''​LSAPI_MAX_PROCESS_TIME''​ environment variable ​controls the total time that PHP process can spend processing a request. It is only effective ​in ProcessGroup or Daemon mode. The parent process ​will kill child processes ​spending more time than this threshold.
  
 +In ProcessGroup mode, ''​LSAPI_MAX_PROCESS_TIME''​ controls the maximum processing time allowed when processing a request. If a child process can not finish processing a request in the given time frame, it will be killed by the parent process. This option can help get rid of dead or runaway child processes.
 ==== LSAPI_PGRP_MAX_IDLE ==== ==== LSAPI_PGRP_MAX_IDLE ====
  
-(default: FOREVER)+Default Value''​FOREVER''​
  
-In ProcessGroup mode, **LSAPI_PGRP_MAX_IDLE** controls how long the parent process will wait before exiting when there are no child processes. This option can help release system resources taken up by an idle parent process. This environment variable has the same function as the Max Idle Time setting ​(WebAdmin console > Configuration > External App).+In ProcessGroup mode, the ''​LSAPI_PGRP_MAX_IDLE''​ environment variable ​controls how long the parent process will wait before exiting when there are no child processes ​running. This option can help release system resources taken up by an idle parent process. This environment variable has the same function as the the **Max Idle Time** setting ​under **Configuration > External App**.
  
 ==== LSAPI_PPID_NO_CHECK ==== ==== LSAPI_PPID_NO_CHECK ====
  
-By default, an LSAPI external application will exit automatically ​if the parent process dies. This is to reduce orphan processes when the web server is restarted. However, it may be desirable to disable this feature in situations such as when an LSAPI process was started manually from the command line. Adding the **LSAPI_PPID_NO_CHECK** environment variable (set it to 1) will disable the checking for the existence of a parent process. To turn off this setting, remove the environment variable completely. When PHP is started from the command line using the "​-b"​ option, checking is disabled automatically.+By default, an LSAPI external application will exit automatically ​when the parent process dies. This is to reduce orphan processes when the web server is restarted. However, it may be desirable to disable this feature in certain ​situationssuch as when an LSAPI process was started manually from the command line.
  
 +Adding the ''​LSAPI_PPID_NO_CHECK''​ environment variable and setting it to ''​1''​ will disable the check for the existence of a parent process. To turn this setting off, remove the environment variable completely. When PHP is started from the command line using the ''​-b''​ option, this check is disabled automatically.
 ==== LSAPI_ALLOW_CORE_DUMP ==== ==== LSAPI_ALLOW_CORE_DUMP ====
  
-By default, an LSAPI application will not leave a core dump file when it crashes. If you want to have LSPHP dump a core file, you should add this environment variable and set to 1. If set, core files will be created under the current working directory, generally the directory of the PHP script that crashed. To turn off this setting, remove the environment variable completely.+By default, an LSAPI application will not leave a core dump file when it crashes. If you want to have LSPHP dump a core file, you should add this environment variable and set to ''​1''​. If set, core files will be created under the current working directory, generally the directory of the PHP script that crashed. To turn off this setting, remove the environment variable completely.
  
 ==== LSAPI_ACCEPT_NOTIFY ==== ==== LSAPI_ACCEPT_NOTIFY ====
  
-By default, an LSAPI application will send back a notification packet whenever a request has been received. ​Since PHP LSAPI 5.0, it can be changed to only notify the server for newly established connections by setting this environment variable to 1. It is recommended as a way to gain performance in LiteSpeed Web Server ​4.1 and later.+By default, an LSAPI application will send back a notification packet whenever a request has been received. ​As of PHP LSAPI v5.0, it can be changed to only notify the server for newly established connections by setting this environment variable to ''​1''​This is recommended as a way to gain performance in LiteSpeed Web Server ​v4.1 and later.
  
 ==== LSAPI_SLOW_REQ_MSECS ==== ==== LSAPI_SLOW_REQ_MSECS ====
  
 If set to a non-zero number, LiteSpeed Web Server will log requests into an error log file if a request takes longer than the specified number of milliseconds. This can help identify scripts that are slowing down your server. If set to a non-zero number, LiteSpeed Web Server will log requests into an error log file if a request takes longer than the specified number of milliseconds. This can help identify scripts that are slowing down your server.
 
litespeed_wiki/php/lsapi-environment-variables.1536941306.txt.gz · Last modified: 2018/09/14 16:08 by Michael Alegre