Management of PHP-FPM

Source: Internet
Author: User
Tags fpm parse error

The pool of PHP-FPM

1. View Files:

[[email protected] ~]# cd /usr/local/php-fpm/etc[[email protected] etc]# lspear.conf  php-fpm.conf  php-fpm.conf.default[[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

2. Modify the configuration file to add Poo:

[[email protected] etc]# vi !$vi php-fpm.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

3. Verify and Reload:

[[email protected] etc]# /usr/local/php-fpm/sbin/php-fpm -t[19-Mar-2018 17:23:16] 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

4. View Status:

[[email protected] etc]# PS aux |grep php-fpmroot 1465 0.0 0.4 227288 4948?        Ss 17:24 0:00 php-fpm:master process (/usr/local/php-fpm/etc/php-fpm.conf) php-fpm 1466 0.0 0.4 227228 4696?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1467 0.0 0.4 227228 4696?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1468 0.0 0.4 227228 4696?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1469 0.0 0.4 227228 4696?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1470 0.0 0.4 227228 4700?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1471 0.0 0.4 227228 4700?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1472 0.0 0.4 227228 4700?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1473 0.0 0.4 227228 4700?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1474 0.0 0.4 227228 4700?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1475 0.0 0.4 227228 4700? S 17:24 0:00 Php-fpm:pOol wwwphp-fpm 1476 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1477 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1478 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1479 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1480 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1481 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1482 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1483 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1484 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1485 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool wwwphp-fpm 1486 0.0 0.4 227228 4700?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1487 0.0 0.4 227228 4700? S 17:24 0:00 PHP-FPM:pool weixing.comphp-fpm 1488 0.0 0.4 227228 4700?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1489 0.0 0.4 227228 4700?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1490 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1491 0.0 0.4 227228 4704?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1492 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1493 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1494 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1495 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1496 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1497 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1498 0.0 0.4 227228 4708? S 17:24 0:00 php-fPm:pool weixing.comphp-fpm 1499 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1500 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1501 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1502 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1503 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1504 0.0 0.4 227228 4708?        S 17:24 0:00 php-fpm:pool weixing.comphp-fpm 1505 0.0 0.4 227228 4708? S 17:24 0:00 php-fpm:pool weixing.comroot 1509 0.0 0.0 112676 984 pts/0 r+ 17:25 0:00 grep--color= Auto PHP-FPM

5. Modify one of the configuration files:

server{    listen 80 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/weixing.sock;        fastcgi_index index.php;        fastcgi_param SCRIPT_FILENAME /data/wwwroot/default$fastcgi_script_name;    }}

6. Define multiple pools, and other sites will not be affected when one of the site requests is full
7.PHP-FPM also supports splitting the pool separately, modifying the configuration file:

[[email protected] vhost]# cd /usr/local/php-fpm/etc/[[email protected] etc]# lspear.conf  php-fpm.conf  php-fpm.conf.default[[email protected] etc]# vi 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. Separate the configuration file: Place two profiles under your own file

[[email protected] etc]# mkdir php-fpm.d[[email protected] etc]# cd php-fpm.d/[[email protected] php-fpm.d]# vi www.conf[[email protected] php-fpm.d]# vi weixing.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
[weixing.com]listen = /tmp/weixing.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

9. Re-verify, load, and view the status as a result:

[r[email protected] php-fpm.d]#/usr/local/php-fpm/sbin/php-fpm-t[19-mar-2018 17:38:49] Notice:configuration File/usr/local/php-fpm/etc/php-fpm.conf test is successful (reverse-i-search) '-reload ': Firewall-cmd-^Ceload[[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-fpmroot 1671 0.0 0.4 227316 4964? Ss 17:39 0:00 php-fpm:master process (/usr/local/php-fpm/etc/php-fpm.conf) php-fpm 1672 0.0 0.4 227256 4        704?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1673 0.0 0.4 227256 4708?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1674 0.0 0.4 227256 4708?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1675 0.0 0.4 227256 4708?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1676 0.0 0.4 227256 4712? S 17:39 0:00 Php-fpm:pool weixing.comphp-fpm 1677 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1678 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1679 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1680 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1681 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1682 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1683 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1684 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1685 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1686 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1687 0.0 0.4 227256 4712? S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1688 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1689 0.0 0.4 227256 4716?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1690 0.0 0.4 227256 4716?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1691 0.0 0.4 227256 4716?        S 17:39 0:00 php-fpm:pool weixing.comphp-fpm 1692 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1693 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1694 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1695 0.0 0.4 227256 4712?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1696 0.0 0.4 227256 4716?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1697 0.0 0.4 227256 4716?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1698 0.0 0.4 227256 4716?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1699 0.0 0.4 227256 4716? S 17:39 0:00 PHp-fpm:pool wwwphp-fpm 1700 0.0 0.4 227256 4716?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1701 0.0 0.4 227256 4716?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1702 0.0 0.4 227256 4716?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1703 0.0 0.4 227256 4716?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1704 0.0 0.4 227256 4716?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1705 0.0 0.4 227256 4720?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1706 0.0 0.4 227256 4720?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1707 0.0 0.4 227256 4720?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1708 0.0 0.4 227256 4720?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1709 0.0 0.4 227256 4720?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1710 0.0 0.4 227256 4720?        S 17:39 0:00 php-fpm:pool wwwphp-fpm 1711 0.0 0.4 227256 4720? S 17:39 0:00 php-fPm:pool wwwroot 1717 0.0 0.0 112680 984 pts/0 s+ 17:39 0:00 grep--color=auto php-fpm 
Slow execution log for PHP-FPM

1. Modify the pool configuration file:

[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 = 1024request_slowlog_timeout = 1slowlog = /usr/local/php-fpm/var/log/www-slow.log

2. Verify and Reload:

[[email protected] php-fpm.d]# /usr/local/php-fpm/sbin/php-fpm -t[19-Mar-2018 17:45:19] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful[[email protected] php-fpm.d]# /etc/init.d/php-fpm reloadReload service php-fpm  done

3. Write a test script:

[[email protected] php-fpm.d]# vim /data/wwwroot/test.com/sleep.php
<?php echo “test slow log”;sleep(2);echo “done”;?>

4. Execution found errors:

[[email protected] php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php <br /><b>Parse error</b>:  syntax error, unexpected ‘slow‘ (T_STRING), expecting ‘,‘ or ‘;‘ in <b>/data/wwwroot/test.com/sleep.php</b> on line <b>2</b><br />

The discovery is the profile punctuation problem, modified after the execution: View the log, found a record

[[email protected] php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php test slow logdone[[email protected] php-fpm.d]# cat /usr/local/php-fpm/var/log/www-slow.log [19-Mar-2018 17:54:53]  [pool www] pid 3202script_filename = /data/wwwroot/test.com/sleep.php[0x00007fbb3f2d3298] sleep() /data/wwwroot/test.com/sleep.php:3
Open_basedir

1. Modify the pool configuration file:

[[email protected] php-fpm.d]# vi 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 = 1024request_slowlog_timeout = 1slowlog = /usr/local/php-fpm/var/log/www-slow.logphp_admin_value[open_basedir]=/data/wwwroot/test.com:/tmp/

2. Test and restart:

[[email protected] php-fpm.d]# /usr/local/php-fpm/sbin/php-fpm -t[19-Mar-2018 18:10:53] 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

3. Access Test: Normal

PHP-FPM Process Management

Management of PHP-FPM

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.