簡體   English   中英

file_get_contents()無法在同一服務器上使用

[英]file_get_contents() not working to same server

我無法使用file_get_contents()從相同的服務器域中獲取內容。

例如 我的域名是mydomain.com

  • 當我有file_get_contents('http://mydomain.com')時,從此服務器收到錯誤消息:

    file_get_contents():無法打開流:連接超時

  • 如果我有file_get_contents('http://google.com')它可以正常工作

  • 如果我將此php腳本file_get_contents('http://mydomain.com')到其他服務器,則它可以正常工作。 但是使用當前服務器卻沒有。

我的服務器:

Ubuntu 12.04
Apache 2.4.9
PHP 5.5.10

allow_url_fopen = on

apt-get upgrade之前一切正常

我發現問題出在哪里:

錯過了

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:72 errors:0 dropped:0 overruns:0 frame:0
          TX packets:72 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:114067 (114.0 KB)  TX bytes:114067 (114.0 KB)

從$ ifconfig

你應該寫這個

$file = file_get_contents('YOUR FILE LOCATION (e.g. /rss.txt)', FILE_USE_INCLUDE_PATH);

這項工作對我來說。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM