2018-05-02 Linux Learning

Source: Internet
Author: User
Tags curl fpm

12.21 PHP-FPM's Pool

vim/usr/local/php/etc/php-fpm.conf//added in [Global] section

Include = etc/php-fpm.d/*.conf

mkdir/usr/local/php/etc/php-fpm.d/
cd/usr/local/php/etc/php-fpm.d/

Vim www.conf//content as follows
[WWW]
Listen =/tmp/php-fcgi.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

Continue editing the configuration file
Vim aming.conf//content as follows
[Aming]
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

/usr/local/php/sbin/php-fpm–t
/ETC/INIT.D/PHP-FPM restart

[[email protected] aming.com]# cd/usr/local/php-fpm/etc/[[email protected] etc]# lspear.conf php-fpm.conf Php-fpm.conf.default php.ini[[email protected] etc]# cat php-fpm.conf[global]pid =/usr/local/php-fpm/var/run/ Php-fpm.piderror_log =/usr/local/php-fpm/var/log/php-fpm.log[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[[email protected] etc]# vim php-fpm.conf Add a bit of content [Aming.com]listen =/tmp/ Aming.socklisten.mode = 666user = Php-fpmgroup = PHP-FPMPM = Dynamicpm.max_children = Pm.start_servers = 20pm.min_spare _servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024[[email protected] etc]#/usr/local/ php-fpm/sbin/php-fpm-t[29-mar-2018 06:33:41] notice:configuration file/usr/local/php-fpm/etc/php-fpm.conf test is Successful[[email protected] etc]#/etc/init.D/PHP-FPM reloadreload service php-fpm done[[email protected] etc]# ps aux | Grep-i PHP-FPM//More than one aming.com[[email protected] etc]# cd/usr/local/nginx/conf/vhost/[[email protected] V host]# lsaaa.com.conf load.conf proxy.conf ssl.conf test.com.conf[[email protected] vhost]# VI aaa.com.conf//Add L    ocation PHP part server{listen default_server;    server_name aaa.com;    Index index.html index.htm index.php;    Root/data/wwwroot/default;        Location ~ \.php$ {include fastcgi_params;        Fastcgi_pass Unix:/tmp/aming.sock;        Fastcgi_index index.php;    Fastcgi_param Script_filename/data/wwwroot/default$fastcgi_script_name; }} Multiple pool, some URLs are inaccessible, other pages are unaffected [[email protected] ~]# cd/usr/local/php-fpm/etc/[[email protected] etc]# lspear.conf php-fpm.conf php-fpm.conf.default php.ini[[email protected] etc]# vim php-fpm.conf//changed to the following [global] PID =/usr/local/php-fpm/var/run/php-fpm.piderror_log =/usr/local/php-fpm/var/log/phP-fpm.loginclude = etc/php-fpm.d/*.conf[[email protected] etc]# mkdir php-fpm.d[[email protected]linux-01 etc]# CD php-fpm.d/[[email protected] php-fpm.d]# vim aming.conf[aming.com]listen =/tmp/aming.socklisten.mode = 666user = Php-fpmgroup = PHP-FPMPM = Dynamicpm.max_children = Pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare _servers = 35pm.max_requests = 500rlimit_files = 1024[[email protected] php-fpm.d]# vim www.conf[www]listen =/tmp/p Hp-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[[email protected] php-fpm.d]#/ usr/local/php-fpm/sbin/php-fpm-t[29-mar-2018 07:00:43] Notice:configuration file/usr/local/php-fpm/etc/ Php-fpm.conf test is successful[[email protected] php-fpm.d]#/etc/init.d/php-fpm restartgracefully shutting down PHP-FPM. donestarting php-fpm done[[email protected] php-fpm.d]# PS aux |grep php-fpm is configured with multiple pool pools, same as the original one php-fpm.conf configured with multiple pool effects 

12.22 php-fpm Slow Execution log

vim/usr/local/php-fpm/etc/php-fpm.d/www.conf//Add the following:
Request_slowlog_timeout = 1
Slowlog =/usr/local/php-fpm/var/log/www-slow.log

Configure Nginx Virtual host test.com.conf, change Unix:/tmp/php-fcgi.sock to Unix:/tmp/www.sock

Reload Nginx Service

vim/data/wwwroot/test.com/sleep.php//write the following:
<?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

Operation Process

[[email protected] php-fpm.d]# vim www.conf //添加如下内容request_slowlog_timeout = 1slowlog = /usr/local/php-fpm/var/log/www-slow.log[[email protected] php-fpm.d]# /usr/local/php-fpm/sbin/php-fpm -t[29-Mar-2018 07:08:29] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful[[email protected] php-fpm.d]# /etc/init.d/php-fpm reload[[email protected] php-fpm.d]# ls /usr/local/php-fpm/var/log/www-slow.log /usr/local/php-fpm/var/log/www-slow.log[[email protected] php-fpm.d]# vim /data/wwwroot/test.com/sleep.php<?phpecho "test slow log";sleep(2);echo "done";?>[[email protected] php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php停顿2秒[[email protected] php-fpm.d]# cat /usr/local/php-fpm/var/log/www-slow.log[29-Mar-2018 08:26:51]  [pool www] pid 15527script_filename = /data/wwwroot/test.com/sleep.php[0x00007f1e35886298] sleep() /data/wwwroot/test.com/sleep.php:3

12.23 Open_basedir

vim/usr/local/php-fpm/etc/php-fpm.d/aming.conf//Add the following:

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

Create a test PHP script to test
Change aming.conf again, modify the path, test again
Configuration error Log
Test again
Viewing the error log

Php-fcgi.sock

Operation Process

[[email protected] php-fpm.d]# vim www.conf    //添加一下内容php_admin_value[open_basedir]=/data/wwwroot/test.com:/tmp/[[email protected] php-fpm.d]# /usr/local/php-fpm/sbin/php-fpm -t[29-Mar-2018 08:32:55] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful[[email protected] php-fpm.d]# /etc/init.d/php-fpm reloa[[email protected] php-fpm.d]# curl -x127.0.0.1:80 test.com/3.php显示phpinfo网页信息

12.24 PHP-FPM Process Management

PM = dynamic/Active process management, also can be static
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.

2018-05-02 Linux Learning

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.