search
HomeBackend DevelopmentPHP TutorialDetailed explanation of php-fpm configuration file

This article introduces some contents of the php-fpm configuration file and configuration options. Friends in need can refer to it.

This section introduces the php-fpm file that comes with php5.3, as follows: /usr/local/php/etc/php-fpm.conf

php-fpm configuration options: pid = run/php-fpm.pid pid setting, the default is var/run/php-fpm.pid in the installation directory, it is recommended to turn it on error_log = log/php-fpm.log Error log, var/log/php-fpm.log in the installation directory by default log_level = notice Error level. Available levels are: alert (must be handled immediately), error (error condition), warning (warning condition), notice (general important information), debug (debugging information). Default: notice. emergency_restart_threshold = 60 emergency_restart_interval = 60s Indicates that if the number of php-cgi processes that have SIGSEGV or SIGBUS errors within the value set by emergency_restart_interval exceeds emergency_restart_threshold, php-fpm will restart gracefully. These two options generally remain at their default values. process_control_timeout = 0 Set the timeout for the child process to accept multiplexed signals from the main process. Available units: s (seconds), m (minutes), h (hours), or d (days) Default unit: s (seconds). Default value: 0. daemonize=yes Execute fpm in the background. The default value is yes, which can be changed to no for debugging. In FPM, it is possible to run multiple process pools with different settings. These settings can be set individually for each process pool. listen = 127.0.0.1:9000 The fpm listening port is the address processed by PHP in nginx. Generally, the default value is sufficient. Available formats are: ‘ip:port’, ‘port’, ‘/path/to/unix/socket’. Each process pool needs to be set. listen.backlog = -1 The number of backlogs, -1 means unlimited, is determined by the operating system, just comment out this line. listen.allowed_clients = 127.0.0.1 Allow access to the IP of the FastCGI process. Set any to unrestricted IP. If you want to set nginx on other hosts to also access this FPM process, set the listen address to a local IP that can be accessed. The default value is any. Each address is separated by a comma. If not set or empty, any server requesting a connection is allowed listen.owner = www listen.group = www listen.mode = 0666 Unix socket setting options, if you use tcp mode to access, just comment here. user=www group=www Account and group to start the process

pm = dynamic How to control the child process, the options are static and dynamic. If static is selected, a fixed number of child processes is specified by pm.max_children. If dynamic is selected, it is determined by the opening parameters: pm.max_children, the maximum number of child processes pm.start_servers, the number of processes at startup pm.min_spare_servers, guarantees the minimum number of idle processes. If the idle processes are less than this value, a new child process will be created. pm.max_spare_servers ensures the maximum number of idle processes. If the idle processes are greater than this value, they will be cleaned up. For dedicated servers, pm can be set to static. pm.max_requests = 1000 Sets the number of requests served before each child process is reborn. 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: 0. pm.status_path = /status The URL of the FPM status page. If not set, the status page cannot be accessed. Default: none. ping.path = /ping The ping URL of the FPM monitoring page. If not set, the ping page cannot be accessed. This page is used to externally detect whether the FPM is alive and can respond to requests. Please note that it must start with a slash (/). ping.response = pong Used to define the return response for ping requests. Returned as HTTP 200 text/plain format text. Default value: pong. request_terminate_timeout = 0 Sets the timeout for a single request. This option may be useful if the 'max_execution_time' setting in php.ini does not abort a running script for some special reason. Set to '0' for 'Off'. You can try changing this option when 502 errors occur frequently. request_slowlog_timeout = 10s When a request expires after the set timeout, the corresponding PHP call stack information will be completely written to the slow log. Setting it to '0' means 'Off' slowlog = log/$pool.log.slow Slow request logging, used in conjunction with request_slowlog_timeout rlimit_files = 1024 Set the rlimit limit for file open descriptors. Default value: system-defined value The system default openable handle is 1024, which can be viewed using ulimit -n and modified with ulimit -n 2048. rlimit_core = 0 Set the maximum limit value of core rlimit. Available values: 'unlimited', 0 or positive integer. Default value: system-defined value. chroot = Chroot directory at startup. The defined directory needs to be an absolute path. If not set, chroot will not be used. chdir = Set the startup directory, which will be automatically Chdired to during startup. The defined directory needs to be an absolute path. Default value: current directory, or / directory (when chrooting) catch_workers_output = yes Redirect stdout and stderr during the running process to the main error log file. If not set, stdout and stderr will be redirected to /dev/null according to FastCGI rules. Default value: empty.



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What data can be stored in a PHP session?What data can be stored in a PHP session?May 02, 2025 am 12:17 AM

PHPsessionscanstorestrings,numbers,arrays,andobjects.1.Strings:textdatalikeusernames.2.Numbers:integersorfloatsforcounters.3.Arrays:listslikeshoppingcarts.4.Objects:complexstructuresthatareserialized.

How do you start a PHP session?How do you start a PHP session?May 02, 2025 am 12:16 AM

TostartaPHPsession,usesession_start()atthescript'sbeginning.1)Placeitbeforeanyoutputtosetthesessioncookie.2)Usesessionsforuserdatalikeloginstatusorshoppingcarts.3)RegeneratesessionIDstopreventfixationattacks.4)Considerusingadatabaseforsessionstoragei

What is session regeneration, and how does it improve security?What is session regeneration, and how does it improve security?May 02, 2025 am 12:15 AM

Session regeneration refers to generating a new session ID and invalidating the old ID when the user performs sensitive operations in case of session fixed attacks. The implementation steps include: 1. Detect sensitive operations, 2. Generate new session ID, 3. Destroy old session ID, 4. Update user-side session information.

What are some performance considerations when using PHP sessions?What are some performance considerations when using PHP sessions?May 02, 2025 am 12:11 AM

PHP sessions have a significant impact on application performance. Optimization methods include: 1. Use a database to store session data to improve response speed; 2. Reduce the use of session data and only store necessary information; 3. Use a non-blocking session processor to improve concurrency capabilities; 4. Adjust the session expiration time to balance user experience and server burden; 5. Use persistent sessions to reduce the number of data read and write times.

How do PHP sessions differ from cookies?How do PHP sessions differ from cookies?May 02, 2025 am 12:03 AM

PHPsessionsareserver-side,whilecookiesareclient-side.1)Sessionsstoredataontheserver,aremoresecure,andhandlelargerdata.2)Cookiesstoredataontheclient,arelesssecure,andlimitedinsize.Usesessionsforsensitivedataandcookiesfornon-sensitive,client-sidedata.

How does PHP identify a user's session?How does PHP identify a user's session?May 01, 2025 am 12:23 AM

PHPidentifiesauser'ssessionusingsessioncookiesandsessionIDs.1)Whensession_start()iscalled,PHPgeneratesauniquesessionIDstoredinacookienamedPHPSESSIDontheuser'sbrowser.2)ThisIDallowsPHPtoretrievesessiondatafromtheserver.

What are some best practices for securing PHP sessions?What are some best practices for securing PHP sessions?May 01, 2025 am 12:22 AM

The security of PHP sessions can be achieved through the following measures: 1. Use session_regenerate_id() to regenerate the session ID when the user logs in or is an important operation. 2. Encrypt the transmission session ID through the HTTPS protocol. 3. Use session_save_path() to specify the secure directory to store session data and set permissions correctly.

Where are PHP session files stored by default?Where are PHP session files stored by default?May 01, 2025 am 12:15 AM

PHPsessionfilesarestoredinthedirectoryspecifiedbysession.save_path,typically/tmponUnix-likesystemsorC:\Windows\TemponWindows.Tocustomizethis:1)Usesession_save_path()tosetacustomdirectory,ensuringit'swritable;2)Verifythecustomdirectoryexistsandiswrita

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use