【问题标题】:PHP request on self对自己的 PHP 请求
【发布时间】:2017-08-29 14:14:46
【问题描述】:

我遇到了自己的 PHP 请求问题。在示例中,我将使用file_get_contents(),但exec('wkhtmltopdf [*SELF*]')curl() 也会发生这种情况

  • 让我的服务器命名为 example.com
  • apache2 已安装
  • FastCGI(多个 PHP 版本 5.3、5.4、5.5、5.6、7.0)
  • 现在我有 2 个虚拟脚本


第一个脚本

//get-html.php  
file_get_contents('http://example.org/index.html')

第二个脚本

//get-php.php
file_get_contents('http://example.org/index.php')


测试
1) 命令行:php get-html.php // 成功
2)浏览器:example.org/get-html.php //成功

1) 命令行:php get-php.php // 成功
2) 浏览器:example.org/get-php.php // 超时


接下来我尝试了什么

  • 创建像subdomain.example.org/index.php 这样的子域,以便为get-php.phpindex.php 提供不同的PHP 版本
  • 修改/etc/hosts
  • 在其他网站(如 google.com)上的请求 // 成功
  • file_get_contents() 之前的 session_write_close() 和之后的 session_start() 也不起作用

所以我的嫌疑人是 mod_fastcgi。似乎 apache 无法运行 2 个实例来处理来自自身的 PHP 请求。从命令行运行脚本按预期工作。

有人有什么建议吗?

【问题讨论】:

  • 虚拟脚本是否完整?您不使用会话(它们也可能会阻塞)
  • 好点马克。忘了提。我也试过 session_write_close(); file_get_contents('example.org/index.php'); session_start();但这也并不成功。现在更新“我接下来尝试了什么”部分。
  • 请暂时不要启动会话(或根本不使用它)并重试,如果问题是由阻塞会话或其他原因引起的,这将回答我们的问题。
  • session_write_close(); file_get_contents('example.org/index.php'); 虽然结果相同 :-( 感谢您的想法

标签: php apache file-get-contents wkhtmltopdf mod-fastcgi


【解决方案1】:

我没有设置 PHP_FCGI_CHILDREN 默认为 1。
当我在 PHP 脚本中通过 apache 从我的服务器调用另一个 PHP 脚本时,它失败了,因为它无法创建另一个 PHP FCGI 实例。

【讨论】:

    猜你喜欢
    • 2014-05-22
    • 1970-01-01
    • 1970-01-01
    • 2013-11-13
    • 2015-03-13
    • 1970-01-01
    • 1970-01-01
    • 2010-12-29
    • 2018-07-06
    相关资源
    最近更新 更多