PHP-FPM pool php-fpm Slow execution log open_basedir PHP-FPM process Management

Source: Internet
Author: User
Tags fpm syslog

One, PHP-FPM pool (configure multiple pools with multiple isolation sites)

#cd/usr/local/php-fpm/etc/
#vim php-fpm.conf//Add configuration file to the second site aming.com, [www] and [aming.com] in the configuration file are equivalent to two different pools

#/usr/local/php-fpm/sbin/php-fpm-t//Check for grammatical errors
#/etc/init.d/php-fpm Reload//restart
#ps aux |grep php-fpm//can view [www] and [aming.com] two different pools
#vim aaa.com.conf//Add the following sections so that two sites are separated from each other.

The benefit of defining multiple pools is that there is a problem with the code for a site, which causes the site to run out of resources, access to the 502 error, and the other site unaffected because they are using different pools
#cd/usr/local/php-fpm/etc/
#cat php-fpm.conf
#vim php-fpm.conf//Add a line of include, delete [www] and [aming.com] two pools

#mkdir/usr/local/php-fpm/etc/php-fpm.d///Create a php-fpm.d/directory
#cd/usr/local/php-fpm/etc/php-fpm.d/
#vim www.conf//Create a www.conf file in the php-fpm.d/directory and write this part of [www] in

#vim aming.conf//Create a aming.conf file, write the [aming.com] part of the content in

#/usr/local/php-fpm/sbin/php-fpm-t
#/etc/init.d/php-fpm Restart//Restart PHP-FPM
Second, php-fpm slow execution log

#vi www.conf//profiles are generally recommended to log for more than 2 seconds

#/usr/local/php-fpm/sbin/php-fpm-t
#/etc/init.d/php-fpm Reload
#ls/usr/local/php-fpm/var/log///Check the/usr/local/php-fpm/var/log/directory for Www-slow.log logs
Php-fpm.log Www-slow.log
#vim/data/wwwroot/test.com/sleep.php//In the/data/wwwroot/test.com/directory to create sleep.php, write the following content can also be written as a line without wrapping

Troubleshooting methods:
#vi/usr/local/php-fpm/etc/php.ini//Search for display_errors in the configuration file, change 466 lines display_errors = off to display_errors = ON, The benefit of this modification is that directly can be done on the page to see what the specific error is
#/etc/init.d/php-fpm Reload
#curl-x127.0.0.1:80 test.com/sleep.php//access under sleep.php
#cat/usr/local/php-fpm/var/log/www-slow.log//View the log will record the slow execution log
Third, Open_basedir

#cd/usr/local/php-fpm/etc/php-fpm.d/
#vi www.conf
Add php_admin_value[open_basedir]=/data/wwwroot/test.com:/tmp/in the last line, note that the path here is to write to, otherwise access
#/etc/init.d/php-fpm restart
#curl-x127.0.0.1:80 test.com/sleep.php//Access status code is 200
#vim/usr/local/php-fpm/etc/php.ini
On-line production environment, the status of Display_errors = off should be defined as off so that no one else can see your error message in the browser
; error_log = Php_errors.log
; Log errors to Syslog (Event Log on Windows).
; error_log = syslog
Error_log =/usr/local/php-fpm/var/log/php-errors.log//Add a row to define the error log path
error_reporting = E_all & ~e_deprecated & ~e_strict//Add a line below this line and comment out this line
Error_reporting =e_all//Add a new line
#grep Error_log/usr/local/php-fpm/etc/php.ini//Find the definition path for the error log
; Server-specific log, STDERR, or a location specified by the Error_log
; Set maximum length of log_errors. In Error_log information on the source is
; error_log = Php_errors.log
; error_log = syslog
Error_log =/usr/local/php-fpm/var/log/php-errors.log
; Opcache error_log file name. Empty string assumes "stderr".
; opcache.error_log=
#ls/usr/local/php-fpm/var/log///view no error log path defined in PHP.ini under this path
Php-fpm.log Www-slow.log
#touch/usr/local/php-fpm/var/log/php-errors.log//Manually create a Php-errors.log file
#chmod 777/usr/local/php-fpm/var/log/php-errors.lo//permissions 777, otherwise the error log cannot be written
#/etc/init.d/php-fpm Restart//restart
#curl-x127.0.0.1:80 test.com/sleep.php//access under sleep.php
#cat/usr/local/php-fpm/var/log/php-errors.log//View error log
Iv. PHP-FPM Process Management

#vim www.conf
[WWW]
Listen =/tmp/php-fcgi.sock
Listen.mode = 666
user = PHP-FPM
Group = PHP-FPM
PM = dynamic//Defines how the process is started (dynamic, static for statics) only the PM is set to dynamic and the following configuration takes effect
Pm.max_children = 50//Defines the maximum number of child processes to start
Pm.start_servers = 20//start of the number of child processes started, default start 20
Pm.min_spare_servers = 5//Idle at least 5 sub-processes, to 5 will automatically increase
Pm.max_spare_servers = 35//idle up to a few sub-processes, up to 35 will be self-tuning
Pm.max_requests = 500//The maximum number of requests per sub-process can be accepted, and the child process will automatically exit when 500 is reached
Rlimit_files = 1024//Number of file handles opened per child process

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.