我在使用fsockopen()或file_get_contents()函数时遇到一些问题
$test = fsockopen("www.google.com", 80, $errno, $errstr, 30);
回复我
Warning: fsockopen(): unable to connect to www.google.com:80 (Connection timed out)
已注册的流套接字传输tcp,udp,unix,udg,ssl,tls,tlsv1.0,tlsv1.1,tlsv1.2
allow_url_fopen =开启
我正在运行php7-fpm + nginx vps并且无法正常运行..
UPDATE 将fsockopen设为ip地址有效......
这是我的etc / resolv.conf
nameserver 213.133.99.99
nameserver 213.133.100.100
nameserver 213.133.98.98
UPDATE curl -vvv http://www.google.com回复
* Hostname was NOT found in DNS cache
* Trying 2a00:1450:4001:811::2004...
* Trying 216.58.214.68...
* Connected to www.google.com (216.58.214.68) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.38.0
> Host: www.google.com
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: private
感谢
答案 0 :(得分:0)
根据您对上一个答案的评论,听起来您的IP已被Google屏蔽,或者您的DNS设置已损坏。
尝试卷曲时会发生什么:
$ curl -vvv http://www.google.com/
如果它是DNS问题,它应该可以直接访问IP:
$ curl 64.233.162.99
如果无效,请尝试其他网站,例如:
$ curl -vvv http://www.stackoverflow.com/
你在运行什么操作系统和VPS?