PHP-File_get_contents在远程服务器上不起作用

时间:2018-10-25 13:31:39

标签: php apache nginx remote-server

file_get_content在运行php 5.6的远程服务器上不起作用。

我只是调用了一个测试脚本 file_get_contents('https://google.com')及其给我以下错误:

Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to 
allocate 319144 bytes) in FILE_PATH on line 14

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('memory_limit', '1024m');

//$opts = array('http'=>array('header' => "User-Agent:MyAgent/1.0\r\n"));
//$context = stream_context_create($opts);
echo "<pre>";
print_r(file_get_contents("https://google.com"));
echo "</pre>";
echo "test";

//$w = stream_get_wrappers();
//echo 'openssl: ',  extension_loaded  ('openssl') ? 'yes':'no', "\n";
//echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "\n";
//echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "\n";
//echo 'wrappers: ', var_export($w);

 ?>

我已经用谷歌搜索,大多数解决方案也改变了

的值

allow_url_fopen设置为1 / on或增加内存限制,但我都做不到。

此外,如果我添加标题,它可以工作,但以前不需要它。

任何帮助都会很有意义。

此外,它正在运行: nginx / 1.6.2 Apache / 2.2.22

0 个答案:

没有答案
相关问题