•   欢迎来到21NN网.
  •   请记住本站网址www.21nn.cn

php-fpm7.0 慢查询设置及申明【php教程】,php-fpm

摘要: 环境申明root@ubuntu:/home/tb#cat/etc/issueUbuntu16.04.2LTS\n\lroot@ubuntu:/home/tb#php-vP...
环境申明

root@ubuntu:/home/tb# cat /etc/issue
Ubuntu 16.04.2 LTS \n \l
root@ubuntu:/home/tb# php -v
PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.15-0ubuntu0.16.04.4, Copyright (c) 1999-2017, by Zend Technologies

检察php-fpm设置途径

root@ubuntu:/home/tb# ps -ef |grep fpm
root      1642     1  0 10:17 ?        00:00:01 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)
www-data  3685  1642  0 17:14 ?        00:00:04 php-fpm: pool www
www-data  3686  1642  0 17:14 ?        00:00:03 php-fpm: pool www
www-data  3808  1642  0 17:43 ?        00:00:03 php-fpm: pool www
root      3930  2208  0 18:10 pts/0    00:00:00 grep --color=auto fpm
root@ubuntu:/home/tb#

php-fpm.conf的末了一行动

include=/etc/php/7.0/fpm/pool.d/*.conf

那我们去那边改www.conf,检察关于慢查询的引见

314 ; The log file for slow requests
315 ; Default Value: not set
316 ; Note: slowlog is mandatory if request_slowlog_timeout is set
317 ;slowlog = log/$pool.log.slow
318
319 ; The timeout for serving a single request after which a PHP backtrace will be
320 ; dumped to the 'slowlog' file. A value of '0s' means 'off'.
321 ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
322 ; Default Value: 0
323 ;request_slowlog_timeout = 0

增加两行设置

slowlog=/var/log/php7.0/fpm/slow.log
request_slowlog_timeout=1s

重启fpm,同时注重目次权限等平常题目

service php7.0-fpm reload

检察log回显效果

[03-Jan-2018 18:48:53]  [pool www] pid 4934
script_filename = /usr/share/nginx/ testapp/index.php
[0x00007fb626213520] session_start() /usr/share/nginx/ testapp/app/models/user_model.php:11
[0x00007fb6262134a0] __construct() /usr/share/nginx/ci_2.2.0/core/Loader.php:303
[0x00007fb626213390] model() /usr/share/nginx/ testapp/app/core/my_Controller.php:39
[0x00007fb6262132e0] __construct() /usr/share/nginx/ testapp/app/controllers/home.php:8
[0x00007fb626213270] __construct() /usr/share/nginx/ci_2.2.0/core/CodeIgniter.php:308
[0x00007fb6262130e0] [INCLUDE_OR_EVAL]() /usr/share/nginx/ testapp/index.php:325
[03-Jan-2018 18:48:53]  [pool www] pid 4931
script_filename = /usr/share/nginx/ testapp/index.php
[0x00007fb626213520] session_start() /usr/share/nginx/ testapp/app/models/user_model.php:11
[0x00007fb6262134a0] __construct() /usr/share/nginx/ci_2.2.0/core/Loader.php:303
[0x00007fb626213390] model() /usr/share/nginx/ testapp/app/core/my_Controller.php:39
[0x00007fb6262132e0] __construct() /usr/share/nginx/ testapp/app/controllers/home.php:8
[0x00007fb626213270] __construct() /usr/share/nginx/ci_2.2.0/core/CodeIgniter.php:308
[0x00007fb6262130e0] [INCLUDE_OR_EVAL]() /usr/share/nginx/ testapp/index.php:325

关于log的申明

[03-Jan-2018 18:48:53]  [pool www] pid 4931

这个没啥诠释,时候历程id

script_filename = /usr/share/nginx/ testapp/index.php

实行剧本称号,php web运用都为单进口

[0x00007fb626213520] session_start() /usr/share/nginx/ testapp/app/models/user_model.php:11

这个第三行比较主要:是客栈顶部信息(is the top of the stack trace),他申明指出了超出了阈值的当前实行的要领的函数挪用是哪一个,以及细致的文件及代码行数

剩下的其他部份就是 挪用的递次(从下往上,终究致使变慢超时的效果)

其他申明

假如发明第三行是以相似curl_exec(),比方:这平常是收集io占用了时候,假如是必需要求第三方,那末。。忍吧。

[0x00007fb6262136f0] curl_exec() /usr/share/nginx/

一样,假如有mysql_query之类的,也是因为sql 慢查询致使的

相干引荐:《PHP教程》

以上就是php-fpm7.0 慢查询设置及申明的细致内容,更多请关注ki4网别的相干文章!

分享到:

发表评论

评论列表

还没有评论,快来说点什么吧~

公众号二维码

微信公众号