【发布时间】:2012-05-01 13:28:07
【问题描述】:
好的,我有两个 Linux 机器在代理服务器后面运行。两个框都设置为通过连接端口 801 绕过过滤。
方框 A - Fedora Core 12 / PHP 5.3.1
方框 B - RHEL 6 / PHP 5.3.3
在 Box A 上,我可以使用 file_get_contents() 连接到外部站点。
<?php
$opts = array(
'http' => array(
'proxy' => 'tcp://10.136.132.1:801',
'request_fulluri' => true
)
);
$cxContext = stream_context_set_default($opts);
echo file_get_contents("http://www.google.com");
这会显示 Google 的主页。
在 Box B 上,我运行相同的代码,但出现此错误:
Warning: file_get_contents(http://www.google.com): failed to open stream: Permission denied
两个盒子都在同一个网络上,在同一个代理服务器后面。我在 Apache 或 PHP 中是否缺少允许 file_get_contents 在 Box B 上工作的设置?
【问题讨论】:
-
print_r($http_response_header) 告诉你什么?
-
在框 B $http_response_header 是一个未定义的变量。在 Box A 上,它在数组中生成标题信息。是否需要打开某些东西才能使其正常工作?
-
如果响应头指示 4xx 错误,则可能不是 PHP 问题
-
我什么也没得到——在 Box B 上,PHP 没有将 $http_response_header 视为系统函数。它认为它是一个没有被声明的变量
标签: php linux apache proxy file-get-contents