PHP 5 Unable to Open HTTP Request Stream with fopen or fsockopen Functions PHP 5中无法打开HTTP请求流与fopen或fsockopen职能

With Apache/2.xx or Apache/2.2.x webserver, with PHP5 as the scripting module, a HTTP communication error may occur within the PHP scripts that are parsing and running via the web server.与apache/2.xx或apache/2.2.x的网络服务器,与php5作为脚本模块, HTTP通信错误,可能会出现内部的PHP脚本是剖析和运行通过网络服务器。

The errors that generated by PHP include:错误所产生的PHP的包括:

PHP Warning: fopen(http://www.example.com): failed to open stream: HTTP request failed! PHP的警告: fopen ( http://www.example.com ) :未能打开流: HTTP请求失败!
fsockopen(): unable to connect to … fsockopen ( ) :无法连接到…
file_get_contents(): failed to open stream: HTTP request failed! file_get_contents ( ) :未能打开流: HTTP请求失败!
PHP Warning: main(): Failed opening ‘http://www.example.com/index.html’ for inclusion … PHP的警告:主( ) :未能开放' http://www.example.com/index.html '列入…
PHP Warning: include(/usr/local/index.php): failed to open stream: No such file or directory in … PHP的警告:包括( / usr / local /下的index.php ) :未能打开流:没有这样的文件或目录在…

To resolve the problem, ensure that allow_url_fopen is enabled in PHP.INI configuration file.要解决这个问题,确保allow_url_fopen启用在php.ini配置文件中。 The line should look like this:线看起来应该是这样的:

allow_url_fopen = On allow_url_fopen =对

Note: Depending on your system OS and configuration, the PHP.INI is located at various varied location, such as in Apache bin directory for Windows system or /usr/local/etc in FreeBSD Apache installation, if you don’t specify or point to PHP.INI in another directory.注:根据您的系统OS和配置,在php.ini是位于各种不同的位置,如在Apache bin目录为Windows系统或/ usr /地方/等在FreeBSD上的Apache安装,如果您不指定或点要在php.ini在另一个目录。

If the error still happen and the PHP scripts still unable to connect to remote external servers and thus unable to download updates or retrieve files, check the user_agent setting in PHP.ini.如果仍存在错误发生和PHP脚本仍然无法连接到远程外部服务器,从而无法下载更新或检索文件,请检查user_agent设置在php.ini的影响。

By default php.ini set the user_agent to “PHP” which signifies that it’s the script that try to access the web server.默认情况下, php.ini的设置user_agent ,以“ php ”的,这意味着它的脚本尝试访问Web服务器。 Some web servers will refuse and don’t allow script to access and receive the date from the server.一些Web服务器将拒绝和不允许脚本访问和收到的日期从服务器。 So, by setting the user_agent to that of a web browser, PHP will let the web server know which kind of web browser will receive the date, and thus able to open the HTTP connection stream.因此,通过设置user_agent这一个网页浏览器, PHP将让Web伺服器知道有哪些种Web浏览器将收到的日期,从而能够打开HTTP连接流。

The user_agent can be set to any kind of browser strings, for example of Internet Explorer:该user_agent可以设定为任何种浏览器的弦乐团,例如Internet Explorer的:

user_agent=”Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)” user_agent = “ mozilla/4.0 (兼容; msie 6.0的Windows NT 5.0 ) ”

IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要说明 :这是一个机器翻译网页是“按原样”提供的担保。 Machine translation may be difficult to understand.机器翻译可能很难理解。 Please refer to请参阅 original English article英文原版的文章 whenever possible.只要有可能。

Share and contribute or get technical support and help at分享和贡献,或取得技术的支持和帮助,在 My Digital Life Forums 我的数字生活论坛 .



Leave a Reply离开的答复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用这些标签:的<a href="" title=""> <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> <删除日期时间= “ ” >的<em>的<i> <q cite=""> <strike>的<strong>

Subscribe without commenting订阅无评论


Custom Search

New Articles新的条款,

Incoming Search Terms for the Article传入的搜索条件文章

failed to open stream: HTTP request failed! 未能打开流: HTTP请求失败! - - failed to open stream: HTTP request failed 未能打开流: HTTP请求失败 - - fsockopen php.ini fsockopen的php.ini - - enable fsockopen 使fsockopen - - file_get_contents failed to open stream file_get_contents未能打开流 - - php http request PHP的HTTP请求 - - failed to open stream: HTTP request failed! 未能打开流: HTTP请求失败! - - file_get_contents php.ini file_get_contents的php.ini - - how to enable fsockopen 如何使fsockopen - - fsockopen php fsockopen的PHP - - php.ini fsockopen php.ini的fsockopen - - fsockopen enable fsockopen启用 - - fsockopen PHP5 fsockopen php5 - - php httprequest PHP的httprequest - - file_get_contents failed to open stream: HTTP request failed! file_get_contents未能打开流: HTTP请求失败! - - php5 fopen php5 fopen - - fopen http request failed fopen HTTP请求失败 - - php enable fsockopen PHP中,使fsockopen - - php open stream PHP中打开流 - - php.ini fsock php.ini的fsock - - httprequest php httprequest的PHP - - fopen php.ini fopen的php.ini - - failed to open stream: HTTP request failed! 未能打开流: HTTP请求失败! - - failed to open stream HTTP request failed 未能打开流的HTTP请求失败 - - "failed to open stream: HTTP request failed" “未能打开流: HTTP请求失败” - - failed to open stream: HTTP request failed! 未能打开流: HTTP请求失败! in 在…内 - - fopen failed to open stream: HTTP request failed! fopen未能打开流: HTTP请求失败! - - fsockopen+php.ini fsockopen + php.ini中 - - fopen failed to open stream HTTP request failed fopen未能打开流的HTTP请求失败 - - fsockopen php ini fsockopen PHP中的INI - - php HTTP request failed PHP的HTTP请求失败 - - fsockopen() enable fsockopen ( ) ,使 - - fsockopen in php fsockopen在PHP - - php.ini fopen php.ini的fopen - - failed to open stream file_get_contents 未能打开流file_get_contents - - php5 fsockopen php5 fsockopen - - "failed to open stream: HTTP request failed!" “未能打开流: HTTP请求失败! ” - - PHP open http stream PHP的开放的HTTP流 - - fopen failed to open stream: HTTP request failed fopen未能打开流: HTTP请求失败 - - php open http PHP的开放的HTTP - - php file_get_contents HTTP request failed PHP的file_get_contents HTTP请求失败 - - php fsockopen site index PHP的fsockopen网站索引 - - file_get_contents HTTP request failed! file_get_contents HTTP请求失败! - - php [function.fopen]: failed to open stream: HTTP request failed! PHP的[ function.fopen ] :未能打开流: HTTP请求失败! - - file_get_contents failed open stream file_get_contents未能打开流 - - enable file_get_contents 使file_get_contents - - fsockopen php http fsockopen的PHP的HTTP - - allow_url_fopen fsockopen allow_url_fopen fsockopen - - enable 'fsockopen' 使' fsockopen ' - - fopen ailed to open stream: HTTP request failed! fopen ailed ,以打开流: HTTP请求失败! - -