国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > Nginx > 正文

詳解php+nginx 服務(wù)發(fā)生500 502錯誤排查思路

2024-08-30 12:24:20
字體:
供稿:網(wǎng)友

概述

當(dāng)線上的服務(wù)中訪問中出現(xiàn)500或者502錯誤時,需要緊急處理,排查問題,該怎么做?可以通過分析一些錯誤日志或者跟蹤php-fpm進程來進行問題定位。

nginx error_log

nginx的error_log在nginx的配置文件中定義的

server { listen  80; server_name localhost; root   /var/www; access_log /Users/jiao/logs/default.access.log; error_log /Users/jiao/logs/default.error.log; location / {  index index.html index.htm index.php;  autoindex on; } location = /info {  allow 127.0.0.1;  deny all;  rewrite (.*) /.info.php; } location ~ /.php$ {  root /var/www;  fastcgi_pass 127.0.0.1:9000;  fastcgi_index index.php;  fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;  include /usr/local/etc/nginx/fastcgi_params; }}

查看error_log

➜  tail /Users/jiao/logs/default.error.log
2019/07/17 11:08:18 [error] 77416#0: *76 kevent() reported about an closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"

發(fā)現(xiàn)出現(xiàn)了Connection reset by peer,連接被重置了,此時可以再查看php-fpm的error_log進一步分析問題

php-fpm error_log

php-fpm的error_log在php-fpm.conf文件中配置中定義的

; Error log file; If it's set to "syslog", log is sent to syslogd instead of being written; in a local file.; Note: the default prefix is /usr/local/var; Default Value: log/php-fpm.logerror_log = log/php-fpm.log

error_log里面的內(nèi)容是這樣的

➜ tail /usr/local/var/log/php-fpm.log[17-Jul-2019 10:49:54] NOTICE: [pool www] child 81948 started[17-Jul-2019 11:08:18] WARNING: [pool www] child 77537, script '/var/www/index.php' (request: "GET /index.php") execution timed out (3.801267 sec), terminating[17-Jul-2019 11:08:18] WARNING: [pool www] child 77537 exited on signal 15 (SIGTERM) after 1503.113967 seconds from start[17-Jul-2019 11:08:18] NOTICE: [pool www] child 94339 started

可以看到是請求/var/www/index.php文件出現(xiàn)了超時

dtruss

dtruss是動態(tài)跟蹤命令,可以根據(jù)PID,name跟蹤進程

mac環(huán)境下使用dtruss,linux環(huán)境可以使用strace,pstack

➜ dtruss USAGE: dtruss [-acdefholLs] [-t syscall] { -p PID | -n name | command | -W name }
  -p PID   # examine this PID  -n name   # examine this process name  -t syscall  # examine this syscall only  -W name   # wait for a process matching this name  -a    # print all details  -c    # print syscall counts  -d    # print relative times (us)  -e    # print elapsed times (us)  -f    # follow children  -l    # force printing pid/lwpid  -o    # print on cpu times  -s    # print stack backtraces  -L    # don't print pid/lwpid  -b bufsize  # dynamic variable buf size            
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 河北省| 来安县| 金沙县| 郯城县| 沅江市| 汾阳市| 宁乡县| 岐山县| 福贡县| 银川市| 贺兰县| 岳池县| 广水市| 彝良县| 大城县| 房产| 沙湾县| 永寿县| 陕西省| 会泽县| 驻马店市| 醴陵市| 台南县| 光山县| 额敏县| 高邮市| 乐平市| 台南县| 红河县| 田阳县| 盐边县| 荔波县| 嘉义县| 普格县| 平舆县| 乳源| 望江县| 江达县| 六盘水市| 白水县| 大足县|