這期內容當中小編將會給大家帶來有關配置php-fpm慢查詢的方法,文章內容豐富且以專業的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
環境說明
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-fpm慢查詢的方法了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注創新互聯成都網站設計公司行業資訊頻道。
另外有需要云服務器可以了解下創新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
文章標題:如何配置php-fpm慢查詢-創新互聯
鏈接分享:http://vcdvsql.cn/article32/ceossc.html
成都網站建設公司_創新互聯,為您提供網站設計、網站收錄、商城網站、做網站、品牌網站設計、用戶體驗
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯