file_get_contents不起作用

时间:2010-03-28 16:25:59

标签: php apache file-get-contents

我正在尝试使用file_get_contents()读取文件 - 它是一个远程HTTP文件,我已经检查了URL并且没关系。只有它不起作用。

更重要的是,错误消息是标准的Firefox服务器错误:

  

连接已重置

     

重置了与服务器的连接   页面正在加载。

...而不是任何形式的PHP错误。它也只需要几秒钟的时间才能回来,所以它不能达到脚本运行时限制 - 任何关于这里出错的想法?​​

Apache 2上的PHP 5,在Windows btw上运行。

澄清它与我的.php文件的连接存在此问题。即使远程文件不存在,我至少也会发现错误 - 我的网络服务器显然正在丢弃连接,而不是至少提供错误消息是问题。

更新2:与fopen而不是file_get_contents相同的问题

更新3:它甚至可能导致服务器崩溃:

[Sun Mar 28 17:46:21 2010] [notice] Server built: Dec 10 2008 00:10:06
[Sun Mar 28 17:46:21 2010] [notice] Parent: Created child process 2720
[Sun Mar 28 17:46:21 2010] [notice] Child 2720: Child process is running
[Sun Mar 28 17:46:21 2010] [notice] Child 2720: Acquired the start mutex.
[Sun Mar 28 17:46:21 2010] [notice] Child 2720: Starting 64 worker threads.
[Sun Mar 28 17:46:21 2010] [notice] Child 2720: Starting thread to listen on port 80.
[Sun Mar 28 17:46:24 2010] [notice] Parent: child process exited with status 255 -- Restarting.
[Sun Mar 28 17:46:24 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Sun Mar 28 17:46:24 2010] [notice] Server built: Dec 10 2008 00:10:06
[Sun Mar 28 17:46:24 2010] [notice] Parent: Created child process 4912
[Sun Mar 28 17:46:24 2010] [notice] Child 4912: Child process is running
[Sun Mar 28 17:46:24 2010] [notice] Child 4912: Acquired the start mutex.
[Sun Mar 28 17:46:24 2010] [notice] Child 4912: Starting 64 worker threads.
[Sun Mar 28 17:46:24 2010] [notice] Child 4912: Starting thread to listen on port 80.
[Sun Mar 28 17:46:31 2010] [notice] Parent: child process exited with status 255 -- Restarting.
[Sun Mar 28 17:46:31 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Sun Mar 28 17:46:31 2010] [notice] Server built: Dec 10 2008 00:10:06
[Sun Mar 28 17:46:31 2010] [notice] Parent: Created child process 2560
[Sun Mar 28 17:46:31 2010] [notice] Child 2560: Child process is running
[Sun Mar 28 17:46:31 2010] [notice] Child 2560: Acquired the start mutex.
[Sun Mar 28 17:46:31 2010] [notice] Child 2560: Starting 64 worker threads.
[Sun Mar 28 17:46:31 2010] [notice] Child 2560: Starting thread to listen on port 80.
[Sun Mar 28 17:46:34 2010] [notice] Parent: child process exited with status 255 -- Restarting.
[Sun Mar 28 17:46:34 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Sun Mar 28 17:46:34 2010] [notice] Server built: Dec 10 2008 00:10:06
[Sun Mar 28 17:46:34 2010] [notice] Parent: Created child process 712
[Sun Mar 28 17:46:34 2010] [notice] Child 712: Child process is running
[Sun Mar 28 17:46:34 2010] [notice] Child 712: Acquired the start mutex.
[Sun Mar 28 17:46:34 2010] [notice] Child 712: Starting 64 worker threads.
[Sun Mar 28 17:46:34 2010] [notice] Child 712: Starting thread to listen on port 80.
[Sun Mar 28 17:49:19 2010] [notice] Parent: child process exited with status 255 -- Restarting.
[Sun Mar 28 17:49:19 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

1 个答案:

答案 0 :(得分:0)

使用cUrl并通过代理建立连接:CURLOPT_HTTPPROXYTUNNEL