configuration

FPM uses php-fpm.conf and process pool configuration files similar to the php.ini syntax.Copy the code

php-fpm.conf

Global configuration segment

pid string

PID file location. The default value is null.

error_log string

Location of the error log. Default: #INSTALL_PREFIX#/log/php-fpm.log If set to syslog, logs are not written to local files but sent to sysLogd.

log_level string

Error level. The available levels are alert, Error, Warning, notice, and DEBUG. Default: notice.

syslog.facility string

Set which program to log messages. Default: daemon.

syslog.ident string

Add a prefix to each message. If you have multiple FPM instances running on the same server, you can change this default value to meet your requirements. Default: php-fpm.

emergency_restart_threshold int

If a child process receives a SIGSEGV or SIGBUS exit message number for the specified number of times within the time set by emergency_restart_interval, the FPM restarts. 0: Disable the function. Default value: 0 (off).

emergency_restart_interval mixed

Emergency_restart_interval Specifies the interval for a smooth restart. This helps solve the problem of shared memory usage in accelerators. Available units: s (seconds), m (minutes), h (hours), or D (days). Default unit: s. Default value: 0 (off).

process_control_timeout mixed

Sets the timeout for the child process to accept the main process’s multiplexing signal. Available units: s (seconds), m (minutes), h (hours), or D (days). Default unit: s. Default value: 0 (off).

process.max int

Fork Specifies the maximum number of FPM processes. When using dynamic process count management, this design can control the global number of processes in a process pool. Use caution. Default value: 0.

process.priority int

Sets the nice(2) priority of the master process if it is set. It can be -19 (highest priority) to 20 (lower priority). Default value: No.

daemonize boolean

Set up FPM to run in the background. Set “no” to keep FPM running in the foreground for debugging. Default value: yes.

rlimit_files int

Set the number of open file descriptors rlimit for the master process.

rlimit_core int

Set the rlimit for the maximum core size of the master process. Default value: 0.

events.mechanism string

Set the event mechanism used by the FPM. The following options are available: Select, Pool, epoll, kQueue (*BSD), port (Solaris) Default: Not set (automatic detection)

systemd_interval int

When using systemd integrated FPM, set interval seconds to report health notification to Systemd. If the value is set to 0, it is disabled. Default value: 10.

Run the configuration section

In FPM, you can run multiple process pools using different Settings. These Settings can be set individually for each process pool.

listen string

Set the address to accept FastCGI requests. The available formats are ‘IP :port’, ‘port’, ‘/path/to/ Unix /socket’. Each process pool needs to be set.

listen.backlog int

Set the backlog maximum for Listen (2). -1 indicates no limit. Default value: -1.

listen.allowed_clients string

Set the server IPV4 address that is allowed to connect to FastCGI. Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in PHP FastCGI (5.2.2+). Only for TCP listening. Each address is separated by commas and, if not set or left empty, allows any server to request a connection. Default value: any. PHP 5.5.20 and 5.6.4 will support IPv6 addresses.

listen.owner string

If a Unix socket is used, indicates its permissions. Read/write permissions must be set in Linux to be used for WEB server connections. In many BSD-derived systems you can ignore permissions to allow free connections. Default value: user and group used for running. Permission is 0660.

listen.group string

See listen. The owner.

listen.mode string

See listen. The owner.

listen.acl_users string

When the system supports POSIX Access Control Lists (ACL), you can set this option. When set, listener. owner and listener. group are ignored. Values are comma-separated lists of user names. Available as of PHP 5.6.5.

listen.acl_groups string

See listen. Acl_users. The value is a comma-separated list of user group names. Available as of PHP 5.6.5.

user string

Unix user who runs the FPM process. This parameter must be set.

group string

The Unix user group that the FPM process runs on. If this parameter is not set, the user group of the default user is used.

pm string

Sets how the process manager manages child processes. Available values: static, ondemand, dynamic. This parameter must be set.

Static – The number of child processes is fixed (pm.max_children).

Ondemand – The process is created when it is required (it is started when requested. In contrast to dynamic, pm.start_Servers is started when the service is started.

Dynamic – The number of child processes is dynamically set based on the configuration: pm.max_children,

  • pm.start_servers
  • pm.min_spare_servers
  • PM. Max_spare_servers.

pm.max_children int

When PM is set to static, the number of child processes can be created. When PM is set to Dynamic, the maximum number of child processes can be created. This parameter must be set.

This option sets the limit on the number of requests that can be served simultaneously. Similar to the MaxClients setting in Apache’s mpm_prefork and the PHP_FCGI_CHILDREN environment variable in plain PHP FastCGI.

pm.start_servers in

Sets the number of child processes to be created at startup. Used only when PM is set to Dynamic. Default value: min_spare_SERVERS + (max_spare_servers-min_spare_servers) / 2.

pm.min_spare_servers int

Set the minimum number of idle server processes. Used only when PM is set to Dynamic. This parameter must be set.

pm.max_spare_servers int

Set the maximum number of idle server processes. Used only when PM is set to Dynamic. This parameter must be set.

pm.process_idle_timeout mixed

Number of seconds, how long before the idle process ends. Only when PM is set to ondemand. Available units: s (seconds), m (minutes), h (hours), or D (days). Default unit: 10s.

pm.max_requests int

Set the number of requests to service each child process before respawning. This is useful for third-party modules that may have memory leaks. If set to ‘0’ requests will always be accepted, equivalent to the PHP_FCGI_MAX_REQUESTS environment variable. Default value: 0.

pm.status_path string

Url of the FPM status page. If this parameter is not set, the status page cannot be accessed. Default value: none.

ping.path string

Ping address of the FPM monitoring page. If the ping page is not set, you cannot access the ping page. This page is used externally to check whether the FPM is alive and ready to respond to requests. Note that it must begin with a slash (/).

ping.response string

Used to define the return response to a ping request. Return HTTP 200 text/plain text. Default value: pong.

process.priority int

Set the worker’s nice(2) priority (if set). The value ranges from -19 (highest priority) to 20 (lower priority). Default value: No

prefix string

Prefix used to detect paths.

request_terminate_timeout mixed

Sets the timeout timeout for a single request. This option may be useful for ‘max_execution_time’ in the php.ini setting if the script is not aborted for some special reason. Setting it to ‘0’ means ‘Off’. Available units: s (seconds), m (minutes), h (hours), or D (days). Default unit: s. Default value: 0 (off).

request_slowlog_timeout mixed

When a request for this timeout is made, the corresponding PHP call stack information is written to the slow log in its entirety. Setting it to ‘0’ means ‘Off’. Available units: s (seconds), m (minutes), h (hours), or D (days). Default unit: s. Default value: 0 (off).

Slowlog String Records logs of slow requests. Default: #INSTALL_PREFIX#/log/php-fpm.log.slow

rlimit_files int

Sets the rlimit limit for the file open descriptor. Default value: system-defined value.

rlimit_core int

Sets the maximum core rlimit value. Available values: ‘unlimited’, 0 or a positive integer. Default value: system-defined value.

chroot string

The Chroot directory at startup. The directory defined needs to be an absolute path. If it is not set, chroot is not used.

chdir string

Set the startup directory. Automatically Chdir to this directory during startup. The directory defined needs to be an absolute path. Default value: current directory or root directory (chroot).

catch_workers_output boolean

Redirect run-time STdout and stderr to the main error log file. If not, stdout and stderr will be redirected to /dev/null according to FastCGI rules. Default value: none

clear_env boolean

Clear environment variables for the FPM worker process. Prevent any system environment variables from entering the FPM worker process until they are set in the process pool configuration file. Since PHP 5.4.27, 5.5.11 and 5.6.0. Default value: Yes

security.limit_extensions string

Limits the script extensions that FPM allows to be parsed. This setting prevents web server configuration errors. FPM should be restricted to parsing only the.php extension to prevent malicious users from running PHP code with other extensions. The default value is.php. Phar

access.log string

Access log files. Default value: No

access.format string

Access log format. Default: “%R – % U %t “%m %R “% s”

Reference:

  • http://php.net/manual/zh/install.fpm.configuration.php FastCGI process manager (FPM) configuration
  • Anziguoer blog