51.PHP-FPM pool, php-fpm slow execution log open_basedir, php-fpm process

Source: Internet
Author: User

First, the pool of PHP-FPM
vim /usr/local/php-fpm/etc/php-fpm.conf          //在[global]部分增加
 include = etc/php-fpm.d/*.conf                        //类似nginx的vhost

 mkdir /usr/local/php-fpm/etc/php-fpm.d/ cd /usr/local/php-fpm/etc/php-fpm.d/
 vim www.conf                                                  //内容如下
[www]listen = /tmp/php-fcgi.socklisten.mode=666user = php-fpmgroup = php-fpmpm = dynamicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024
    • Continue editing the configuration file
 vim chinantfy.conf //内容如下
[chinantfy]listen = /tmp/chinantfy.socklisten.mode=666user = php-fpmgroup = php-fpmpm = dynamicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024
/usr/local/php-fpm/sbin/php-fpm -t /etc/init.d/php-fpm restart/reload            //重启或者重新加载配置文件 ps aux | grep php-fpm

ls /usr/local/nginx/conf/vhost/vim /usr/local/nginx/conf/vhost/test.com.conf

  • Select different connection pools by specifying different sock two, php-fpm slow execution log (used to locate PHP Web site access is slow)
    vim /usr/local/php-fpm/etc/php-fpm.d/www.conf      //加入如下内容request_slowlog_timeout = 1        //超过1秒就会记录,一般用2 即可slowlog = /usr/local/php-fpm/var/log/www-slow.log

  • Reload Nginx Service
    /usr/local/nginx/sbin/nginx -t/etc/init.d/nginx  reload
    vim /data/wwwroot/test.com/sleep.php         //写入如下内容<?php echo "test slow log";sleep(2);echo "done";?>

    curl -x127.0.0.1:80 test.com/sleep.php cat /usr/local/php-fpm/var/log/www-slow.log

  • Log file shows that the third line of PHP causes slow running

    Third, PHP-FPM definition Open_basedir
    vim /usr/local/php-fpm/etc/php-fpm.d/www.conf    //加入如下内容
    php_admin_value[open_basedir]=/data/wwwroot/123test.com:/tmp/      //注意这里路径特意改错了
    /usr/local/php-fpm/sbin/php-fpm -t/etc/init.d/php-fpm reload
    curl -x127.0.0.1:80 test.com/sleep.php  -I

  • Configuration error Log
    vi /usr/local/php-fpm/etc/php.ini   //修改下面两行error_log=/usr/local/php-fpm/var/log/php_errors.1ogerror_reporting =E_ALL
    /usr/local/php-fpm/sbin/php-fpm -t/etc/init.d/php-fpm reload
  • Manually generate log files and modify permissions
    touch /usr/local/php-fpm/var/log/php_errors.1ogchmod 777 /usr/local/php-fpm/var/log/php_errors.1og
  • Test again
    curl -x127.0.0.1:80 test.com/sleep.php  -I

  • Change www.conf again, modify the path, test again

    php_admin_value[open_basedir]=/data/wwwroot/test.com:/tmp//usr/local/php-fpm/sbin/php-fpm -t/etc/init.d/php-fpm reload

    Test again
    Viewing the error log

    Iv. PHP-FPM Process Management
    cat /usr/local/php-fpm/etc/php-fpm.d/www.conf

    PM = dynamic/Active process management, can also be static when the following line settings do not take effect
    Pm.max_children = 50//maximum number of sub-processes, PS aux can be viewed
    Pm.start_servers = 20//Number of processes that will start 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.

51.PHP-FPM pool, php-fpm slow execution log open_basedir, php-fpm process

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.