php-doc-en/install/fpm/configuration.xml
2021-04-24 20:01:17 +03:00

931 lines
29 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="install.fpm.configuration" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Configuration</title>
<para>
FPM uses &php.ini; syntax for its configuration file - <filename>php-fpm.conf</filename>, and pool configuration files.
</para>
<sect2>
<title>List of global <filename>php-fpm.conf</filename> directives</title>
<variablelist>
<varlistentry xml:id="pid">
<term>
<parameter>pid</parameter>
<type>string</type>
</term>
<listitem>
<para>
Path to PID file. Default value: none.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="error-log">
<term>
<parameter>error_log</parameter>
<type>string</type>
</term>
<listitem>
<para>
Path to error log file. Default value:
<literal>#INSTALL_PREFIX#/log/php-fpm.log</literal>.
If it's set to "syslog", log is sent to syslogd instead of being written in a local file.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="log-level">
<term>
<parameter>log_level</parameter>
<type>string</type>
</term>
<listitem>
<para>
Error log level. Possible values: alert, error, warning, notice,
debug. Default value: notice.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="log-limit">
<term>
<parameter>log_limit</parameter>
<type>int</type>
</term>
<listitem>
<para>
Log limit for the logged lines which allows to log messages longer than
1024 characters without wrapping.
Default value: 1024.
Available as of PHP 7.3.0.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="log-buffering">
<term>
<parameter>log_buffering</parameter>
<type>bool</type>
</term>
<listitem>
<para>
Experimental logging without extra buffering.
Default value: yes.
Available as of PHP 7.3.0.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="syslog-facility">
<term>
<parameter>syslog.facility</parameter>
<type>string</type>
</term>
<listitem>
<para>
used to specify what type of program is logging the message.
Default value: daemon.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="syslog-ident">
<term>
<parameter>syslog.ident</parameter>
<type>string</type>
</term>
<listitem>
<para>
Prepended to every message.
If you have multiple FPM instances running on the same server,
you can change the default value which must suit common needs.
Default value: php-fpm.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="emergency-restart-threshold">
<term>
<parameter>emergency_restart_threshold</parameter>
<type>int</type>
</term>
<listitem>
<para>
If this number of child processes exit with SIGSEGV or SIGBUS within
the time interval set by <literal>emergency_restart_interval</literal>,
then FPM will restart. A value of 0 means 'Off'. Default value: 0 (Off).
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="emergency-restart-interval">
<term>
<parameter>emergency_restart_interval</parameter>
<type>mixed</type>
</term>
<listitem>
<para>
Interval of time used by <literal>emergency_restart_interval</literal> to determine when
a graceful restart will be initiated. This can be useful to work around
accidental corruptions in an accelerator's shared memory.
Available Units: s(econds), m(inutes), h(ours), or d(ays).
Default Unit: seconds. Default value: 0 (Off).
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="process-control-timeout">
<term>
<parameter>process_control_timeout</parameter>
<type>mixed</type>
</term>
<listitem>
<para>
Time limit for child processes to wait for a reaction on signals from
master. Available units: s(econds), m(inutes), h(ours), or d(ays)
Default Unit: seconds. Default value: 0.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="process-max">
<term>
<parameter>process.max</parameter>
<type>int</type>
</term>
<listitem>
<para>
The maximum number of processes FPM will fork. This has been design
to control the global number of processes when using dynamic PM
within a lot of pools. Use it with caution.
Default value: 0.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="process-priority">
<term>
<parameter>process.priority</parameter>
<type>int</type>
</term>
<listitem>
<para>
Specify the nice(2) priority to apply to the master process (only if set).
The value can vary from -19 (highest priority) to 20 (lower priority).
Default value: not set.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="daemonize">
<term>
<parameter>daemonize</parameter>
<type>bool</type>
</term>
<listitem>
<para>
Send FPM to background. Set to 'no' to keep FPM in foreground for
debugging. Default value: yes.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="rlimit-files-master">
<term>
<parameter>rlimit_files</parameter>
<type>int</type>
</term>
<listitem>
<para>
Set open file descriptor rlimit for the master process.
Default value: Set open file descriptor rlimit for the master process.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="rlimit-core-master">
<term>
<parameter>rlimit_core</parameter>
<type>int</type>
</term>
<listitem>
<para>
Set max core size rlimit for the master process.
Default value: 0.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="events-mechanism">
<term>
<parameter>events.mechanism</parameter>
<type>string</type>
</term>
<listitem>
<para>
Specify the event mechanism FPM will use.
The following is available: select, pool, epoll, kqueue (*BSD), port (Solaris).
Default value: not set (auto detection).
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="systemd-interval">
<term>
<parameter>systemd_interval</parameter>
<type>int</type>
</term>
<listitem>
<para>
When FPM is build with systemd integration, specify the interval,
in second, between health report notification to systemd.
Set to 0 to disable.
Default value: 10.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2>
<title>List of pool directives</title>
<para>
With FPM you can run several pools of processes with different setting.
These are settings that can be tweaked per pool.
</para>
<variablelist>
<varlistentry xml:id="listen">
<term>
<parameter>listen</parameter>
<type>string</type>
</term>
<listitem>
<para>
The address on which to accept FastCGI requests. Valid syntaxes are:
'ip.add.re.ss:port', 'port', '/path/to/unix/socket'. This option is
mandatory for each pool.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="listen-backlog">
<term>
<parameter>listen.backlog</parameter>
<type>int</type>
</term>
<listitem>
<para>
Set listen(2) backlog. A value of '-1' means unlimited. Default value:
-1.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="listen-allowed-clients">
<term>
<parameter>listen.allowed_clients</parameter>
<type>string</type>
</term>
<listitem>
<para>
List of IPv4 addresses of FastCGI clients which are allowed to
connect. Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the
original PHP FastCGI (5.2.2+). Makes sense only with a tcp listening socket.
Each address must be separated by a comma. If this value is left blank,
connections will be accepted from any ip address. Default value: any.
IPv6 addresses are allowed.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="listen-owner">
<term>
<parameter>listen.owner</parameter>
<type>string</type>
</term>
<listitem>
<para>
Set permissions for unix socket, if one is used. In Linux, read/write
permissions must be set in order to allow connections from a web
server. Many BSD-derived systems allow connections regardless of permissions.
Default values: user and group are set as the running user, mode is set to 0660.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="listen-group">
<term>
<parameter>listen.group</parameter>
<type>string</type>
</term>
<listitem>
<para>
See <literal>listen.owner</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="listen-mode">
<term>
<parameter>listen.mode</parameter>
<type>string</type>
</term>
<listitem>
<para>
See <literal>listen.owner</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="listen-acl-users">
<term>
<parameter>listen.acl_users</parameter>
<type>string</type>
</term>
<listitem>
<para>
When POSIX Access Control Lists are supported you can set them using this option.
When set, <literal>listen.owner</literal> and <literal>listen.group</literal>
are ignored. Value is a comma separated list of user names.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="listen-acl-groups">
<term>
<parameter>listen.acl_groups</parameter>
<type>string</type>
</term>
<listitem>
<para>
See <literal>listen.acl_users</literal>.
Value is a comma separated list of group names.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="user">
<term>
<parameter>user</parameter>
<type>string</type>
</term>
<listitem>
<para>
Unix user of FPM processes. This option is mandatory.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="group">
<term>
<parameter>group</parameter>
<type>string</type>
</term>
<listitem>
<para>
Unix group of FPM processes. If not set, the default user's group is
used.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pm">
<term>
<parameter>pm</parameter>
<type>string</type>
</term>
<listitem>
<para>
Choose how the process manager will control the number of child
processes. Possible values: <literal>static</literal>, <literal>ondemand</literal>,
<literal>dynamic</literal>.
This option is mandatory.
</para>
<para>
<literal>static</literal> - the number of child processes is fixed (<literal>pm.max_children</literal>).
</para>
<para>
<literal>ondemand</literal> - the processes spawn on demand (when requested,
as opposed to dynamic, where <literal>pm.start_servers</literal> are started
when the service is started.
</para>
<para>
<literal>dynamic</literal> - the number of child processes is set dynamically based on the
following directives: <literal>pm.max_children</literal>, <literal>pm.start_servers</literal>,
<literal>pm.min_spare_servers</literal>, <literal>pm.max_spare_servers</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pm.max-children">
<term>
<parameter>pm.max_children</parameter>
<type>int</type>
</term>
<listitem>
<para>
The number of child processes to be created when <literal>pm</literal> is set to
<literal>static</literal> and the maximum number of child processes to be created
when <literal>pm</literal> is set to <literal>dynamic</literal>. This
option is mandatory.
</para>
<para>
This option sets the limit on the number of simultaneous requests that
will be served. Equivalent to the ApacheMaxClients directive with
mpm_prefork and to the <varname>PHP_FCGI_CHILDREN</varname> environment variable in the
original PHP FastCGI.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pm.start-servers">
<term>
<parameter>pm.start_servers</parameter>
<type>int</type>
</term>
<listitem>
<para>
The number of child processes created on startup.
Used only when <literal>pm</literal> is set to <literal>dynamic</literal>.
Default Value: min_spare_servers + (max_spare_servers -
min_spare_servers) / 2.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pm.min-spare-servers">
<term>
<parameter>pm.min_spare_servers</parameter>
<type>int</type>
</term>
<listitem>
<para>
The desired minimum number of idle server processes. Used only when
<literal>pm</literal> is set to <literal>dynamic</literal>. Also
mandatory in this case.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pm.max-spare-servers">
<term>
<parameter>pm.max_spare_servers</parameter>
<type>int</type>
</term>
<listitem>
<para>
The desired maximum number of idle server processes. Used only when
<literal>pm</literal> is set to <literal>dynamic</literal>. Also
mandatory in this case.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pm.process-idle-timeout">
<term>
<parameter>pm.process_idle_timeout</parameter>
<type>mixed</type>
</term>
<listitem>
<para>
The number of seconds after which an idle process will be killed.
Used only when <literal>pm</literal> is set to <literal>ondemand</literal>.
Available units: s(econds)(default), m(inutes), h(ours), or d(ays).
Default value: 10s.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pm.max-requests">
<term>
<parameter>pm.max_requests</parameter>
<type>int</type>
</term>
<listitem>
<para>
The number of requests each child process should execute before
respawning. This can be useful to work around memory leaks in 3rd party
libraries. For endless request processing specify '0'. Equivalent to
<varname>PHP_FCGI_MAX_REQUESTS</varname>. Default value: 0.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="pm.status-path">
<term>
<parameter>pm.status_path</parameter>
<type>string</type>
</term>
<listitem>
<para>
The URI to view the FPM status page. If this value is not set, no URI
will be recognized as a status page. Default value: none.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="ping.path">
<term>
<parameter>ping.path</parameter>
<type>string</type>
</term>
<listitem>
<para>
The ping URI to call the monitoring page of FPM. If this value is not
set, no URI will be recognized as a ping page. This could be used to test
from outside that FPM is alive and responding. Please note that the value must
start with a leading slash (/).
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="ping.response">
<term>
<parameter>ping.response</parameter>
<type>string</type>
</term>
<listitem>
<para>
This directive may be used to customize the response to a ping
request. The response is formatted as text/plain with a 200 response code.
Default value: pong.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="worker-process-priority">
<term>
<parameter>process.priority</parameter>
<type>int</type>
</term>
<listitem>
<para>
Specify the nice(2) priority to apply to the worker process (only if set).
The value can vary from -19 (highest priority) to 20 (lower priority).
Default value: not set.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="process-dumpable">
<term>
<parameter>process.dumpable</parameter>
<type>bool</type>
</term>
<listitem>
<para>
Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
or group is different than the master process user. It allows to create process
core dump and ptrace the process for the pool user.
Default Value: no. Since PHP 7.0.29, 7.1.17 and 7.2.5.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="prefix">
<term>
<parameter>prefix</parameter>
<type>string</type>
</term>
<listitem>
<para>
Specify prefix for path evaluation
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="request-terminate-timeout">
<term>
<parameter>request_terminate_timeout</parameter>
<type>mixed</type>
</term>
<listitem>
<para>
The timeout for serving a single request after which the worker
process will be killed. This option should be used when the 'max_execution_time'
ini option does not stop script execution for some reason. A value of '0' means
'Off'. Available units: s(econds)(default), m(inutes), h(ours), or d(ays).
Default value: 0.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="request-slowlog-timeout">
<term>
<parameter>request_slowlog_timeout</parameter>
<type>mixed</type>
</term>
<listitem>
<para>
The timeout for serving a single request after which a PHP backtrace
will be dumped to the 'slowlog' file. A value of '0' means 'Off'.
Available units: s(econds)(default), m(inutes), h(ours), or d(ays).
Default value: 0.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="slowlog">
<term>
<parameter>slowlog</parameter>
<type>string</type>
</term>
<listitem>
<para>
The log file for slow requests. Default value:
<literal>#INSTALL_PREFIX#/log/php-fpm.log.slow</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="rlimit-files">
<term>
<parameter>rlimit_files</parameter>
<type>int</type>
</term>
<listitem>
<para>
Set open file descriptor rlimit for child processes in this pool. Default value: system defined value.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="rlimit-core">
<term>
<parameter>rlimit_core</parameter>
<type>int</type>
</term>
<listitem>
<para>
Set max core size rlimit for child processes in this pool. Possible Values: 'unlimited' or an integer greater or equal to 0.
Default value: system defined value.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="chroot">
<term>
<parameter>chroot</parameter>
<type>string</type>
</term>
<listitem>
<para>
Chroot to this directory at the start. This value must be defined as
an absolute path. When this value is not set, chroot is not used.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="chdir">
<term>
<parameter>chdir</parameter>
<type>string</type>
</term>
<listitem>
<para>
Chdir to this directory at the start. This value must be an absolute
path. Default value: current directory or / when chroot.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="catch-workers-output">
<term>
<parameter>catch_workers_output</parameter>
<type>bool</type>
</term>
<listitem>
<para>
Redirect worker stdout and stderr into main error log. If not set,
stdout and stderr will be redirected to /dev/null according to FastCGI specs.
Default value: no.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="decorate-workers-output">
<term>
<parameter>decorate_workers_output</parameter>
<type>bool</type>
</term>
<listitem>
<para>
Enable the output decoration for workers output when <link
linkend="catch-workers-output">catch_workers_output</link> is enabled.
Default value: yes.
Available as of PHP 7.3.0.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="clear-env">
<term>
<parameter>clear_env</parameter>
<type>bool</type>
</term>
<listitem>
<para>
Clear environment in FPM workers.
Prevents arbitrary environment variables from reaching FPM worker processes
by clearing the environment in workers before env vars specified in this
pool configuration are added.
Default value: Yes.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="security-limit-extensions">
<term>
<parameter>security.limit_extensions</parameter>
<type>string</type>
</term>
<listitem>
<para>
Limits the extensions of the main script FPM will allow to parse.
This can prevent configuration mistakes on the web server side.
You should only limit FPM to .php extensions to prevent malicious
users to use other extensions to execute php code.
Default value: .php .phar
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="access-log">
<term>
<parameter>access.log</parameter>
<type>string</type>
</term>
<listitem>
<para>
The access log file.
Default value: not set
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="access-format">
<term>
<parameter>access.format</parameter>
<type>string</type>
</term>
<listitem>
<para>
The access log format.
Default value: <literal>"%R - %u %t \"%m %r\" %s"</literal>:
<table xml:id="fpm.configuration.access.format">
<title>Valid options</title>
<tgroup cols="2">
<thead>
<row>
<entry>Placeholder</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<constant>%C</constant>
</entry>
<entry>%CPU</entry>
</row>
<row>
<entry>
<constant>%d</constant>
</entry>
<entry>duration µs</entry>
</row>
<row>
<entry>
<constant>%e</constant>
</entry>
<entry>fastcgi env</entry>
</row>
<row>
<entry>
<constant>%f</constant>
</entry>
<entry>script</entry>
</row>
<row>
<entry>
<constant>%l</constant>
</entry>
<entry>content length</entry>
</row>
<row>
<entry>
<constant>%m</constant>
</entry>
<entry>method</entry>
</row>
<row>
<entry>
<constant>%M</constant>
</entry>
<entry>memory</entry>
</row>
<row>
<entry>
<constant>%n</constant>
</entry>
<entry>pool name</entry>
</row>
<row>
<entry>
<constant>%o</constant>
</entry>
<entry>header output</entry>
</row>
<row>
<entry>
<constant>%p</constant>
</entry>
<entry>PID</entry>
</row>
<row>
<entry>
<constant>%q</constant>
</entry>
<entry>query string</entry>
</row>
<row>
<entry>
<constant>%Q</constant>
</entry>
<entry>the glue between %q and %r</entry>
</row>
<row>
<entry>
<constant>%r</constant>
</entry>
<entry>request URI</entry>
</row>
<row>
<entry>
<constant>%R</constant>
</entry>
<entry>remote IP address</entry>
</row>
<row>
<entry>
<constant>%s</constant>
</entry>
<entry>status</entry>
</row>
<row>
<entry>
<constant>%T</constant>
</entry>
<entry>time</entry>
</row>
<row>
<entry>
<constant>%t</constant>
</entry>
<entry>time</entry>
</row>
<row>
<entry>
<constant>%u</constant>
</entry>
<entry>remote user</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
It's possible to pass additional environment variables and update PHP settings of a certain pool.
To do this, you need to add the following options to the pool configuration file.
<example>
<title>Passing environment variables and PHP settings to a pool</title>
<programlisting role="ini">
<![CDATA[
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 32M
]]>
</programlisting>
</example>
PHP settings passed with <literal>php_value</literal> or
<literal>php_flag</literal> will overwrite their previous value.
Please note that defining
<link linkend="ini.disable-functions">disable_functions</link> or
<link linkend="ini.disable-classes">disable_classes</link> will
not overwrite previously defined <filename>php.ini</filename> values,
but will append the new value instead.
</para>
<para>
Settings defined with <literal>php_admin_value</literal> and <literal>php_admin_flag</literal>
cannot be overridden with <function>ini_set</function>.
</para>
<para>
As of 5.3.3, PHP settings are also possible to be set in webserver.
<example>
<title>set PHP settings in nginx.conf</title>
<programlisting role="ini">
<![CDATA[
set $php_value "pcre.backtrack_limit=424242";
set $php_value "$php_value \n pcre.recursion_limit=99999";
fastcgi_param PHP_VALUE $php_value;
fastcgi_param PHP_ADMIN_VALUE "open_basedir=/var/www/htdocs";
]]>
</programlisting>
</example>
<caution>
<para>
Because these settings are passed to php-fpm as fastcgi headers,
php-fpm should not be bound to a worldwide accessible address.
Otherwise, anyone could alter the PHP configuration options.
See also
<link linkend="listen-allowed-clients">listen.allowed_clients</link>.
</para>
</caution>
</para>
</sect2>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->