·设为首页收藏本站📧邮箱修改🎁免费下载专区📒收藏夹👽聊天室📱AI智能体
返回列表 发布新帖

单独启动nginx和phpcgi无法访问UCenter

237 2
发表于 2023-6-18 09:37:52 | 查看全部 阅读模式

马上注册,免费下载更多dz插件网资源。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
问题需求:
  1,点击 站长 ==》UCenter设置 后,正常显示通信成功
  2,window环境

问题描述:
  1,用apache 部署 -正常
  2,用phpstudy_pro 启动nginx(会自动启动 php-cgi) - 正常
  3,curl -X POST http://localhost/upload/uc_server/index.php?__times__=1 我尝试用命令 竟然可以请求通。 - 正常
  3,手动启动nginx 和 php-cgi.exe -b 127.0.0.1:9899 -c php.ini 后  - 连接不通,nginx提示错误如下:手动启动的时候,都是在window环境下 以管理员的身份运行的。
  1.    2023/06/18 08:02:05 [error] 13016#24968: *4 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream,     client: 127.0.0.1, server: localhost, request: "POST /upload/uc_server/index.php?__times__=1 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"
复制代码

问题:
  1,求大佬指点,问题出在那里
我知道答案 回答被采纳将会获得1 贡献 已有1人回答
我要说一句 收起回复

评论2

拾光Lv.8 发表于 2023-6-18 09:38:20 | 查看全部
nginx 配置 我觉得是没问题的。
  1. server {        listen        80;        server_name  localhost;        root   "D:/app/Apache24/htdocs";        location / {            # index index.php index.html;            # First attempt to serve request as file, then            # as directory, then fall back to displaying a 404.            try_files $uri $uri/index.php /index.php?$query_string;            error_page 400 /error/400.html;            error_page 403 /error/403.html;            error_page 404 /error/404.html;            error_page 500 /error/500.html;            error_page 501 /error/501.html;            error_page 502 /error/502.html;            error_page 503 /error/503.html;            error_page 504 /error/504.html;            error_page 505 /error/505.html;            error_page 506 /error/506.html;            error_page 507 /error/507.html;            error_page 509 /error/509.html;            error_page 510 /error/510.html;            include D:/app/Apache24/htdocs/nginx.htaccess;            autoindex  off;        }        location ~ \.php(.*)$ {            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            fastcgi_param  PATH_INFO  $fastcgi_path_info;            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;            include        fastcgi_params;        }    }
复制代码
我要说一句 收起回复
Discuz智能体Lv.8 发表于 2025-3-14 03:39:22 | 查看全部
根据您描述的情况和Nginx的错误日志分析,问题可能出在以下几个方面:

1. **PHP-CGI端口监听不一致**
- 您手动启动PHP-CGI时指定的端口是`9899`(`-b 127.0.0.1:9899`)
- 但Nginx错误日志显示上游地址是`fastcgi://127.0.0.1:9000`
- 解决方法:修改Nginx配置中的fastcgi_pass参数,使其与实际PHP-CGI端口一致

2. **PHP-CGI进程未正确启动**
建议检查以下步骤:
  1. # 查看端口监听情况(cmd执行)
  2. netstat -ano | findstr ":9899"
  3. # 查看php-cgi进程是否存在
  4. tasklist | findstr "php-cgi"
复制代码


3. **正确的配置流程**
建议按以下步骤重新配置:

  1. # Nginx配置文件示例
  2. location ~ \.php$ {
  3.     root           html;
  4.     fastcgi_pass   127.0.0.1:9899; # 必须与php-cgi启动端口一致
  5.     fastcgi_index  index.php;
  6.     fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  7.     include        fastcgi_params;
  8. }
复制代码


4. **Windows环境特别注意事项**
- 建议使用完整路径启动php-cgi:
  1. start /B php-cgi.exe -b 127.0.0.1:9899 -c C:\php\php.ini
复制代码

- 检查防火墙设置,允许9899端口的入站连接
- 确保PHP.ini中开启必要扩展:
  1. extension=curl
  2. extension=openssl
  3. extension=mbstring
复制代码


5. **UCenter通信专用检查**
在完成上述配置后,建议进行以下验证:
  1. # 测试PHP解析是否正常
  2. curl -I http://localhost/upload/uc_server/index.php

  3. # 测试UCenter通信接口
  4. curl -X POST http://localhost/upload/uc_server/index.php -d "m=admin&a=test"
复制代码


如果仍然出现`10054`错误,建议在Nginx配置中添加:
  1. fastcgi_read_timeout 300; # 适当延长超时时间
复制代码


请特别注意:当手动启动php-cgi时,该进程不会像php-fpm那样自动管理,需要保持命令行窗口持续运行。如果需要后台运行,可以使用以下vbs脚本:
  1. Set WshShell = CreateObject("WScript.Shell")
  2. WshShell.Run "php-cgi.exe -b 127.0.0.1:9899", 0
  3. Set WshShell = Nothing
复制代码


建议按照这个顺序排查,先确保PHP解析正常,再处理UCenter通信问题。如果仍无法解决,可以提供更多环境细节(PHP版本、Nginx配置完整片段等)进一步分析。
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。
我要说一句 收起回复

回复

 懒得打字嘛,点击右侧快捷回复【查看最新发布】   【应用商城享更多资源】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

图文热点
关闭

站长推荐上一条 /1 下一条

AI智能体
投诉/建议联系

discuzaddons@vip.qq.com

未经授权禁止转载,复制和建立镜像,
如有违反,按照公告处理!!!
  • 联系QQ客服
  • 添加微信客服

联系DZ插件网微信客服|最近更新|Archiver|手机版|小黑屋|DZ插件网! ( 鄂ICP备20010621号-1 )|网站地图 知道创宇云防御

您的IP:3.17.71.93,GMT+8, 2025-4-3 00:12 , Processed in 0.326820 second(s), 81 queries , Gzip On, Redis On.

Powered by Discuz! X5.0 Licensed

© 2001-2025 Discuz! Team.

关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表