12.21 PHP-FPM's Pool

Source: Internet
Author: User

12.21 PHP-FPM's Pool

Unlike lamp, in the LNMP architecture, a PHP-FPM-seat standalone service exists. Since it is a standalone service, it must have its own configuration file.

The PHP-FPM configuration file is/usr/local/php-fpm/etc/php-fpm.conf, which also supports the include statement, similar to the include in nginx.conf.

Nginx can configure multiple virtual hosts, PHP-FPM also support the configuration of multiple pool, each pool can listen to a port (Ip:port), can also listen to a socket.

Why isolate Pool?

Because if a pool has a site that has a problem, such as one of the sites taking up a large amount of resources, causing other sites to run slow, or crashing, so this will implicate the other sites in the pool.


Define Pool

1 entering the php-fpm/etc/configuration directory

[Email protected] ~]# cd/usr/local/php-fpm/etc/

[[email protected] etc]# ls

pear.conf php-fpm.conf Php-fpm.conf.default php.ini

2 Add the pool, named Aming.com, with the following parameters.

[Email protected] etc]# vim Php-fpm.conf[aming.com]listen =/tmp/aming.sock#listen = 127.0.0.1:9000listen.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

3-T checks the syntax and restarts or reload after the addition is complete.

[Email protected] etc]#/usr/local/php-fpm/sbin/php-fpm-t

[02-may-2018 11:32:20] Notice:configuration file/usr/local/php-fpm/etc/php-fpm.conf Test is successful


[Email protected] etc]#/ETC/INIT.D/PHP-FPM Reload

Reload Service PHP-FPM Done

4 Review the process to see if there are more pool (aming.com) just configured on the right side of the process

5 Modify aaa.com Monitor aming socket, add the following parameters

Location ~ \.php$ {include fastcgi_params;        Fastcgi_pass unix:/tmp/php-fcgi.sock;# Fastcgi_pass 127.0.0.1:9000;        Fastcgi_index index.php;    Fastcgi_param Script_filename/data/wwwroot/default$fastcgi_script_name; }}

6 Add the include syntax to split the pool configuration file conf

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

[Email protected] php-fpm.d]#!vim

Vim/usr/local/php-fpm/etc/php-fpm.conf

[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

6.1 Copying parameters

Create a PHP-FPM.D directory

[Email protected] etc]# mkdir PHP-FPM.D

[Email protected] etc]# CD php-fpm.d/

[Email protected] php-fpm.d]# cat/usr/local/php-fpm/etc/php-fpm.conf

[Email protected] php-fpm.d]# vim www.conf

6.2 Copying the WWW parameter to www.conf

[Www]listen =/tmp/php-fcgi.sock#listen = 127.0.0.1:9000listen.mode = 666user = Php-fpmgroup = PHP-FPMPM = Dynamicpm.max_c Hildren = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024


[Email protected] php-fpm.d]# vim aming.conf

6.3 Copying aming.com parameters to aming.conf

[Aming.com]listen =/tmp/aming.sock#listen = 127.0.0.1:9000listen.mode = 666user = Php-fpmgroup = PHP-FPMPM = dynamicpm.ma X_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1 024


6.4 [[email protected] php-fpm.d]# ls

Aming.conf www.conf


7 After the copy is complete, delete the parameters of the php-fpm.conf two pool, add the include syntax, and then delete it to see how neat the parameters are.

[email protected] php-fpm.d]# cat!$

Cat/usr/local/php-fpm/etc/php-fpm.conf

[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


8 Check the syntax and reload.

[Email protected] php-fpm.d]#/usr/local/php-fpm/sbin/php-fpm-t

[02-may-2018 12:07:00] Notice:configuration file/usr/local/php-fpm/etc/php-fpm.conf Test is successful

[Email protected] php-fpm.d]#/etc/init.d/php-fpm restart

Gracefully shutting down php-fpm. Done

Starting php-fpm Done

9 Check process after reboot

Summarize

Reasons for defining multiple pool:

If the test.com request is now large, it will eventually run out of PHP-FPM process.

Up to 50 sub-processes can be started, but after 50 processes are started, all are busy and new requests come in.

The 502 status code will be reported at this time because there is no redundant PHP-FPM process to request the listener service.

Another pool (aming.com) request will not be affected because it is another pool.


12.21 PHP-FPM's Pool

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.