PHP CURL对于localhost来说太慢了 [英] PHP CURL is too slow for localhost
问题描述
我在我的WAMP环境中设置了两个应用程序。两个网站的性能是好的。它们在不到一秒钟内返回数据。问题是,当我从另一个卷曲一个网站卷曲大约需要20秒来回应。我做了profiling。实际上CURL请求是所有的时间。
I have setup two apps in my WAMP environment. Performance of both the sites is OK. They return data in less than a second. The problem is that when I curl one site from another the curl takes around 20 seconds to respond. I have done profiling. Actually CURL request is taking all the time.
这不应该是这样的情况,因为两个网站都在我的机器上设置,我使用localhost / 127.0.0.1。
This should not be the case as both sites are setup on my machine and I am accessing using localhost/127.0.0.1 . Is it some sort of DNS resolve issue?
推荐答案
我有同样的问题,终于发现它是来自两个事实:
I had the same problem and finally discover that it was coming from two facts :
- 我使用Mac OS X Mavericks
- 我通过URL访问了我的项目
http://myproject.local/
,因为我在/ etc中放了一行
127.0.0.1 myproject.local
/ hosts
- I use Mac OS X Mavericks
- I accessed my project via the URL
http://myproject.local/
because I put a line127.0.0.1 myproject.local
in/etc/hosts
这是因为 .local
tld保留给Bonjour服务,这是从Mac OS X Lion(10.7)开始的。
It is because the .local
tld is reserved for Bonjour service, and this since Mac OS X Lion (10.7).
更改tld以修复问题。
Changing the tld for something else fixed the problem.
这篇关于PHP CURL对于localhost来说太慢了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!