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所博客
- Comments and Comment Blocks in PHP意見和評論座在PHP
































