当前位置: 首页 > news >正文

WordPress报502错误问题解决-php-fpm-84.service loaded failed failed LSB: starts php-fpm

文章目录

    • 问题描述
    • 问题排查
    • 问题解决

问题描述

服务器环境:

  • php:8.4
  • MySQL:8.0
  • Nginx:1.26.2

在访问站点时,一直报502,而两天前还能正常访问。

image-20250307132158647

问题排查

导致502的问题很多,比如站点访问量太大,站点受到了攻击等,但是我看了后台,重启了Nginx,也没解决。现在遇到问题,首选就用AI来诊断。

我先复制了网站的错误日志:

2025/03/07 13:16:26 [crit] 795740#0: *2451 connect() to unix:/tmp/php-cgi-84.sock failed (2: No such file or directory) while connecting to upstream, client: 66.249.66.21, server: www.imqd.cn, request:GET /robots.txt HTTP/1.1, upstream: "fastcgi://unix:/tmp/php-cgi-84.sock:, host: "www.imqd.cn"
2025/03/07 13:16:26 [crit] 795740#0: *2450 connect() to unix:/tmp/php-cgi-84.sock failed (2: No such file or directory) while connecting to upstream, client: 66.249.66.1, server: www.imqd.cn, request:GET /tag/es6 HTTP/1.1, upstream: "fastcgi://unix:/tmp/php-cgi-84.sock:, host: "www.imqd.cn"

丢给ChatGPT,然后它回复的解决方案有点多,我用了下面这一条:

# 将该指令复制,并在站点目录下执行命令行
systemctl list-units --type=service | grep php

输出:

php-fpm-74.service                       loaded active running LSB: starts php-fpm
● php-fpm-84.service                     loaded failed failed  LSB: starts php-fpm

错误如上:

表示我的环境中安装了2个php版本,其中Nginx 试图使用 PHP 8.4 (php-fpm-84),但它 无法启动,所以 502 Bad Gateway

问题解决

这个我之前是用PHP8.4来运行WordPress站点的,现在它的服务遇到了问题,导致502问题。

所以很简单的解决方式就是将WordPress的PHP版本切换为7.4即可。

image-20250307132721010

但是为什么会导致8.4 用不了呢?wp运行在PHP8中更安全。

查看PHP的日志:

[14-Feb-2025 04:04:02] NOTICE: child 322153 stopped for tracing
[14-Feb-2025 04:04:02] NOTICE: about to trace 322153
[14-Feb-2025 04:04:02] NOTICE: finished trace of 322153
[15-Feb-2025 17:18:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 1 idle, and 22 total children
[15-Feb-2025 17:18:05] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 3 idle, and 26 total children
[16-Feb-2025 17:52:51] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 2 idle, and 27 total children
[16-Feb-2025 17:52:52] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 3 idle, and 30 total children
[16-Feb-2025 17:52:53] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 2 idle, and 32 total children
[17-Feb-2025 04:01:49] WARNING: [pool www] child 1221397, script '/www/wwwroot/www.cn/wp-admin/admin-ajax.php' (request: "GET /wp-admin/admin-ajax.php?action=wordfence_doScan&isFork=0&scanMode=standard&cronKey=c1d5082357026a61a2ce6e9feff7f549&signature=31aa3d000f5f2053ad504322212ad58a52a5a0e3032b25317bbdc7ef656b0606") executing too slow (34.708130 sec), logging
[17-Feb-2025 04:01:49] NOTICE: child 1221397 stopped for tracing
[17-Feb-2025 04:01:49] NOTICE: about to trace 1221397
[17-Feb-2025 04:01:49] NOTICE: finished trace of 1221397
[17-Feb-2025 10:57:21] NOTICE: Terminating ...
[17-Feb-2025 10:57:21] NOTICE: exiting, bye-bye!

发现了2个问题:

PHP-FPM 进程池(pool www)资源不足,服务器负载过高

  • 日志多次提示 seems busy,说明 PHP 进程太少,导致请求等待时间变长
  • 你可能需要 增加 PHP-FPM 的进程数pm.start_serverspm.min/max_spare_servers)。

某些 PHP 脚本执行太慢,导致超时

  • 日志中显示 admin-ajax.php 执行时间过长(34.7 秒),可能是 WordPress 插件(如 Wordfence)在运行扫描任务,影响了服务器性能。

所以归根结底还是服务器配置不够,并且因为我开启了Wordfence插件扫描导致的原因。


如果你在开发WordPress时遇到了问题,可以在下方与我联系,作为你的WordPress顾问。

http://www.lryc.cn/news/547991.html

相关文章:

  • Python在SEO中的自动化应用爬虫开发与日志分析实例
  • thingsboard edge 在windows 环境下的配置
  • nnMamba:基于状态空间模型的3D生物医学图像分割、分类和地标检测
  • nginx 配置403页面(已亲测)
  • SyntaxError: Invalid or unexpected token in JSON at position x
  • Uncaught TypeError: Cannot read properties of undefined (reading ‘xxx‘)
  • Nginx 跨域配置详细讲解
  • 前端开发基石:HTML语义化深度解析与实践指南
  • mongodb安装教程以及mongodb的使用
  • C# 中的多线程同步机制:lock、Monitor 和 Mutex 用法详解
  • 【通义万相】蓝耘智算 | 开源视频生成新纪元:通义万相2.1模型部署与测评
  • 期权帮|中证1000股指期权交割结算价怎么算?
  • Python 面向对象高级编程-定制类
  • qt creator示例空白
  • MyBatis-Plus 与 Spring Boot 的最佳实践
  • TDengine 中的标签索引
  • 工业自动化核心:BM100 信号隔离器的强大力量
  • Ascend开发板镜像烧录、联网、其他设备访问
  • Llama-Factory框架下的Meta-Llama-3-8B-Instruct模型微调
  • MySQL进阶-分析查询语句EXPLAIN
  • Python 高级编程与实战:构建数据可视化应用
  • 学习threejs,Animation、Core、CustomBlendingEquation、Renderer常量汇总
  • Java直通车系列14【Spring MVC】(深入学习 Controller 编写)
  • 【蓝桥杯集训·每日一题2025】 AcWing 5539. 牛奶交换 python
  • Mybatis缓存机制(一级缓存和二级缓存)
  • 设计模式--单例模式
  • ubuntu22.04本地部署OpenWebUI
  • 2025-3-7二叉树的线索化
  • 以商业思维框架为帆,驭创业浪潮前行
  • 海思Hi3516DV300交叉编译opencv