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 我的数字生活论坛 . 。
Related Articles相关文章
- Making phpBB2 working with PHP5决策phpbb2工作与php5
- PHP Parse Error: syntax error, unexpected $end PHP的解析错误:语法错误,意想不到的元月底
- gmmktime Error in WordPress and MagpieRSS gmmktime误差在WordPress和magpierss
- Proper Way to Generate MD5 Hash for XCache Administration Password with md5sum or PHP正确的做法产生MD5哈希为xcache政府密码与md5sum或php
- PHP Scripts open_basedir Restriction in Effect Error PHP脚本和open_basedir的限制,实际上是错误
- Aerielle Launches New i2i Stream Wireless Music-Sharing Device aerielle推出新i2i流的无线音乐共享设备
- Meaning of TVAnts Buffer Progress Bar Colors含义tvants缓冲进度栏的颜色
- Unable to Delete Photo Folders无法删除图片文件夹
- Using PHP-MySQL Persistent Connections to Run WordPress Blog使用PHP - MySQL的持久连接运行的WordPress所博客
- Access and Stream Your Videos, Musics, Photos, TV and Other Medias Remotely with Orb获取和流您的影片,音乐,照片,电视和其他媒体进行远程与ORB的


















