8.17 php-fpm pool, php-fpm slow execution log, Open_basedir, PHP-FPM process Management

Source: Internet
Author: User
Tags fpm

1, the pool of PHP-FPM

  Edit Profile vim/usr/local/php/etc/php-fpm.conf, at which point only one pool is defined, the WWW

You can define multiple pool, listen to different addresses or sockets, and if you have multiple sites, you can use multiple pool so that when one of the sites is 502, it does not affect the normal access of other sites.

Add the following section to the configuration file, vim/usr/local/php/etc/php-fpm.conf

[Aming.com]

Listen =/tmp/aming.sock

listen.mode=666

user = PHP-FPM

Group = PHP-FPM

PM = dynamic

Pm.max_children = 50

Pm.start_servers = 20

Pm.min_spare_servers = 5

Pm.max_spare_servers = 35

Pm.max_requests = 500

Rlimit_files = 1024

Perform/usr/local/php-fpm/sbin/php-fpm-t to verify that the configuration file is correct

Then reload the service/etc/init.d/php-fpm reload

Perform PS aux |grep php-fpm to see the aming.com process

2. PHP-FPM Slow Execution log

Analyze your site for slow response by viewing logs.

To edit the configuration file vim/usr/local/php-fpm/etc/php-fpm.d/www.conf, add the following:

Request_slowlog_timeout = 1/Record request for more than one second

Slowlog =/usr/local/php-fpm/var/log/www-slow.log//Log storage location

Then check the configuration file and reload

With LS you can see that the corresponding log file has been generated under the specified directory

At this point, in order to verify the log content, you need to make a slow request, edit the configuration file vim/data/wwwroot/test.com/sleep.php, add the following:

<?php

echo "Test slow Log";

Sleep (2); Sleep for two seconds

echo "Done";

?>

At this point, when the access is made, the request sleeps for 2 seconds, uses the Curl command, and then views the log

3, Open_basedir

You can define open_basedir for different pool

To edit the configuration file vim/usr/local/php-fpm/etc/php-fpm.d/aming.conf, add the following:

php_admin_value[open_basedir]=/data/wwwroot/aming.com:/tmp/

4. PHP-FPM Process Management

PM = dynamic process management, can be static, only dynamic, the following configuration will take effect, if it is static, only the bank in force

Pm.max_children = 50//maximum number of sub-processes, PS aux can be viewed

Pm.start_servers = 20//Number of processes started by default when the service is started

Pm.min_spare_servers = 5//Defines the minimum number of child processes in the idle period, and if this value is reached, the PHP-FPM service automatically derives the new child process.

Pm.max_spare_servers = 35//Defines the maximum number of child processes in the idle period, or, if higher than this value, to start cleaning up idle child processes.

Pm.max_requests = 500//defines the maximum number of requests processed by a child process, that is, a PHP-FPM child process can handle so many requests, and when this value is reached, it exits automatically.

8.17 php-fpm pool, php-fpm slow execution log, Open_basedir, PHP-FPM process management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.