moqiang02

虽然可以在浏览器中正常访问http://localhost但用file,file_get_contents等函数打开http://localhost异常。用127.0.0.1也可以打开,本地hosts指向也正常,尝试ping localhost结果返回的是::1,推测不是httpd和php的配置问题,是php不能识别::1所致

>ping localhost
reply from ::1: times<1ms
reply from ::1: times<1ms
reply from ::1: times<1ms

应该是返回127.0.0.1,::1显然是错误的,不过为什么呢,hosts文件也没有错啊

127.0.0.1 localhost

这导致php的file_get_contents,getimagesize等函数不能打开“http://localhost”开头的,只可以打开“http://127.0.0.1”开头的。

卸载ipv6:ipv6 uninstall

一切恢复正常。

分类:

技术点:

相关文章:

  • 2021-04-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-02-09
  • 2021-12-29
  • 2021-08-23
相关资源
相似解决方案