我有两台服务器 s1 和 s2。我有一个来自 s1 的文件试图访问从 s2 到 php curl 的文件。curl 命令是在 s1/test 中使用 php 编写的.php它请求 s2/file.php。
我测试了 s1 中是否存在 curl,并且它与除 s2 以外的所有 url 都能正常工作。我也可以从本地主机访问 s2,但不能从 s1 访问。请帮助我。
这是我的卷曲代码:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "here the url is placed");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, '');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
if(!$data)
{
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
echo $data;
当我执行时,我得到:"卷曲错误:无法连接到主机"
couldn't connect to host
表示 2 台服务器之间的连接有问题。检查 DNS、IP 的防火墙、打开的端口和服务...
在从 s1 到 s2 的 CLI 中运行wget
说明了什么?