我正在尝试通过PHP脚本与同一服务器上的3个网站建立FTP连接。它适用于其中两个站点,但第三个我得到以下错误(它似乎不是暂时的):
“警告:ftp_connect()[function.ftp-connect]:php_network_getaddresses:getaddrinfo failed:这通常是主机名解析期间的临时错误,意味着本地服务器没有收到来自权威服务器的响应”
此代码段是失败的地方:
$server = 'ftp.'.$ftp_server;
$conn_id = ftp_connect($server) OR die("<br>unable to establish an FTP connection");
我希望有人能指出我正确的方向。
关心所有
答案 0 :(得分:5)
这意味着ftp服务器名称的DNS查找(例如example.com
)无法解析,无法确定IP地址。
这可能是您的远程站点的DNS服务器关闭,或者域本身配置错误,并指向不存在/无法访问的DNS服务器。
答案 1 :(得分:1)
该特定主机的DNS服务器可能已关闭;检查域的whois
条记录,以发现哪些DNS服务器具有权威性,然后依次使用host
检查每个DNS服务器,以确保它们全部解析。
例如,whois stackoverflow.com
:
Name Servers:
ns1.serverfault.com
ns2.serverfault.com
ns3.serverfault.com
然后:
$ host www.stackoverflow.com ns1.serverfault.com
Using domain server:
Name: ns1.serverfault.com
Address: 64.34.119.33#53
Aliases:
www.stackoverflow.com is an alias for stackoverflow.com.
stackoverflow.com has address 64.34.119.12
stackoverflow.com mail is handled by 10 STACKOVERFLOW.COM.S9A1.PSMTP.com.
stackoverflow.com mail is handled by 20 STACKOVERFLOW.COM.S9A2.PSMTP.com.
stackoverflow.com mail is handled by 30 STACKOVERFLOW.COM.S9B1.PSMTP.com.
stackoverflow.com mail is handled by 40 STACKOVERFLOW.COM.S9B2.PSMTP.com.
$ host www.stackoverflow.com ns2.serverfault.com
Using domain server:
Name: ns2.serverfault.com
Address: 64.34.119.34#53
Aliases:
www.stackoverflow.com is an alias for stackoverflow.com.
stackoverflow.com has address 64.34.119.12
stackoverflow.com mail is handled by 30 STACKOVERFLOW.COM.S9B1.PSMTP.com.
stackoverflow.com mail is handled by 40 STACKOVERFLOW.COM.S9B2.PSMTP.com.
stackoverflow.com mail is handled by 10 STACKOVERFLOW.COM.S9A1.PSMTP.com.
stackoverflow.com mail is handled by 20 STACKOVERFLOW.COM.S9A2.PSMTP.com.
$ host www.stackoverflow.com ns3.serverfault.com
Using domain server:
Name: ns3.serverfault.com
Address: 69.59.196.217#53
Aliases:
www.stackoverflow.com is an alias for stackoverflow.com.
stackoverflow.com has address 64.34.119.12
stackoverflow.com mail is handled by 30 STACKOVERFLOW.COM.S9B1.PSMTP.com.
stackoverflow.com mail is handled by 40 STACKOVERFLOW.COM.S9B2.PSMTP.com.
stackoverflow.com mail is handled by 10 STACKOVERFLOW.COM.S9A1.PSMTP.com.
stackoverflow.com mail is handled by 20 STACKOVERFLOW.COM.S9A2.PSMTP.com.
$
所有三台服务器都响应www.stackoverflow.com
的请求,因此所有三台服务器都正常运行。