PHP CURL从特定服务器到另一特定服务器不起作用 [英] PHP CURL from a specific server to another specific server not working

查看:116
本文介绍了PHP CURL从特定服务器到另一特定服务器不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个服务器s1和s2。我有一个来自s1的文件,试图通过php curl从s2访问一个文件。 curl命令是使用s1 / test.php中的php编写的,它正在请求s2 / file.php。

I have two servers s1 and s2. I have a file from s1 trying to access a file from s2 through php curl. The curl commands are written using php in s1/test.php and it is requesting s2/file.php.

我测试了s1中是否存在curl并且它可以正常工作除s2以外的所有网址都可以。我也可以从本地主机访问s2,但不能从s1访问。请帮助我。

I tested if curl is present in s1 and it is working fine with all urls except from s2. Also I can access s2 from localhost but not from s1. Please help me.

这是我的卷曲代码:

$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;

当我执行时,我得到:卷曲错误:无法连接到主机

When i execute I am getting: "Curl error: couldn't connect to host"

推荐答案

无法连接到主机表示两者之间的连接存在问题2台服务器。检查DNS,ip的防火墙,打开的端口和服务...

couldn't connect to host means that sonmething is wrong with the connection between the 2 servers. Check DNS's, ip's firewalls, opened ports and services...

从s1在CLI中运行 wget 是什么到s2说?

What does running wget in the CLI from s1 to s2 says?

这篇关于PHP CURL从特定服务器到另一特定服务器不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆