You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nginx连接php8.1-fpm.sock失败,API页面502/500错误求助

PHP-FPM套接字关联Nginx 502/500错误排查求助

项目是线上运行的私有仓库地图网站(基于OpenLayers),其他成员本地部署正常,但我本地环境存在PHP-FPM套接字相关问题:

  • 95%页面可正常加载,地图功能无问题
  • API路径http://localhost/api/返回nginx/1.18.0 (Ubuntu)的502 Bad Gateway错误,多数API依赖PHP

Nginx错误日志

2024/12/20 19:44:55 [error] 24#24: *1 connect() to unix:/run/php/php8.1-fpm.sock failed (111: Unknown error) while connecting to upstream, client: 172.18.0.1, server: localhost, request: "GET /api/map_dates/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "localhost", referrer: "http://localhost/us/map2/"
2024/12/20 20:28:05 [crit] 526#526: *4 connect() to unix:/run/php/php8.1-fpm.sock failed (95: Unknown error) while connecting to upstream, client: 172.18.0.1, server: localhost, request: "GET /api/map_dates/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "localhost", referrer: "http://localhost/us/map2/"

已做的配置修改

  • compose.yaml:注释- ${WEB_RUNTIME_ROOT_DIR}/sitez/var/run:/var/run,修改entrypoint为创建并授权/run/php目录后启动服务
  • Dockerfile:添加RUN mkdir -p /run/php && chown www-data:www-data /run/php && chmod 0755 /run/php
  • nginx.conf:在location ~ [^/]\.php(/|$)中注释include snippets/fastcgi-php.conf,在location /api/中添加fastcgi相关配置
  • www.conf:将套接字监听配置移至用户组配置上方,取消注释listen.mode = 0660

当前状态

修改后仅少数API页面可部分加载,仅能显示php_info();或单个print('Here');语句,无此类输出时返回500错误;尝试改用TCP端口也未解决问题,请求帮助排查。

内容的提问来源于stack exchange,提问作者mendesd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 11:12:14