标签 php-fpm 下的文章

wordpress的php执行超时 - connect_timeout - nginx - php7.4

问题: debian 11默认安装的nginx和php7.4-fpm,在wordpress扫描经sftp上传的图片导到媒体库时,经常提示Ajax错误。nginx错误日志为:upstream timed out (110: Connection timed out) while reading response header from upstream。

尝试:在站点的php配置内容中,适当加大超时时间,如:

fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
fastcgi_connect_timeout 600;

参考:https://stackoverflow.com/questions/59713432/nginx-php-fpm-fastcgi-upstream-timed-out

在debian 9中为php7.0-fpm启用状态查询

如有php站点响应慢,出现504等错误,可以尝试启用php-fpm的状态显示和慢查询功能来辅助诊断。

环境:debian9,php7.0-fpm, nginx

过程:

1.nano /etc/php/7.0/fpm/pool.d/www.conf # 编辑默认的php-fpm www配置文件

2.pm.status_path = /status # 移除注释,启用状态查询页

3.添加以下两行,启用慢查询记录:

slowlog = /var/log/nginx/$pool.log.slow
request_slowlog_timeout = 10

4.systemctl restart php7.0-fpm # 重启php-fpm进程

5.nano /etc/nginx/sites-enabled/default # 编辑nginx的默认站点配置,在适合位置添加:

        location /status {
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                log_not_found off;
        }

debian-php-fpm-status-1.png

6.systemctl restart nginx # 重启nginx服务

7.在浏览器里访问状态查询页,如 http://szt.anqun.org/status?full ,可以看到相应数据
debian-php-fpm-status-2.png

参考: