【问题标题】:Apache HTTP Server has stopped working - curlApache HTTP Server 已停止工作 - curl
【发布时间】:2012-09-15 15:54:25
【问题描述】:

我使用curl从页面获取数据

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $page);     
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
    $str = curl_exec($curl);
    curl_close($curl);
    $raw= str_get_html($str);

$page 是页面的网址

效果很好,但是当我尝试从大于正常的页面获取数据时,我的 apache 停止响应

这是 apache 日志:

[Sat Sep 15 10:17:36 2012] [notice] Apache/2.2.21 (Win32) PHP/5.3.9 configured -- resuming normal operations
[Sat Sep 15 10:17:36 2012] [notice] Server built: Sep 10 2011 11:34:11
[Sat Sep 15 10:17:36 2012] [notice] Parent: Created child process 3908
[Sat Sep 15 10:17:36 2012] [notice] Child 3908: Child process is running
[Sat Sep 15 10:17:36 2012] [notice] Child 3908: Acquired the start mutex.
[Sat Sep 15 10:17:36 2012] [notice] Child 3908: Starting 64 worker threads.
[Sat Sep 15 10:17:36 2012] [notice] Child 3908: Starting thread to listen on port 8080.
[Sat Sep 15 10:17:53 2012] [notice] Parent: child process exited with status 3221225477 -- Restarting.

我认为页面大小是个问题(不确定),有人可以确认吗?有没有办法解决这个问题?我试图增加 php.ini 中的 memory_alocation 但它没有帮助

【问题讨论】:

  • 和“比正常大”是指更可测量单位的尺寸?
  • 你知道你正在加载的内容的大小吗?
  • 另外,没有memory_alocation配置项。你的意思是memory_limit?
  • 当我说大于正常时,我的意思是带有女巫的更大页面,它可以正常工作。当我保存页面时,它是 231 KB 的 htm 文件。是的,我指的是 memory_limit

标签: php apache curl


【解决方案1】:

您的 Web 应用程序是否在 Windows 上运行?如果是这样,这篇文章可能会有所帮助:http://www.java-samples.com/showtutorial.php?tutorialid=1050

【讨论】:

  • 是的,我确实看到了,并尝试过,但它没有解决我的问题,相同的脚本适用于任何其他页面
【解决方案2】:

也许你的 php 页面因为获取页面持续时间太长而超时,你可以使用 set_time_limit() 禁用超时,如下所示:

set_time_limit(0);

将该行放在脚本的开头。

【讨论】:

  • 我确实在 curl curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10) 中设置了时间限制;但我没有时间我得到 apache 崩溃
  • 该超时选项适用于 cURL,我说的是 PHP 超时,您运行这些 cURL 调用的页面可能会超时,与您的 CURLOPT_CONNECTTIMEOUT 选项无关。默认的 php 超时时间是 30 秒。
猜你喜欢
  • 2017-04-17
  • 2015-02-08
  • 2016-06-02
  • 2015-12-02
  • 2016-03-11
  • 2018-05-20
  • 1970-01-01
  • 2015-03-10
  • 1970-01-01
相关资源
最近更新 更多