卷曲在Apache显示.."禁止访问!错误403" [英] cURL on Apache showing .. "Access forbidden! Error 403"

查看:1082
本文介绍了卷曲在Apache显示.."禁止访问!错误403"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试简单的API与卷曲。它是,从(的PHP文件)一个Apache服务器来(的PHP文件)的另一个Apache服务器调用。这是当地确定测试。但是,当我用我的网络PC测试,它显示出以下403错误:

I am testing simple API with cURL. It is, calling from (a php file of) one Apache Server to (a php file of) another Apache Server. It is ok testing locally. But when i test with my network PCs, it showing following 403 error:

禁止访问!
您没有权限访问请求的对象。它要么读保护或不被服务器读取。
如果你认为这是一个服务器错误,请与网站管理员联系。
错误403

codeS为来电服务器(服务器1):结果

Codes for Caller Server (Server 1) are:

function apicall($request_url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $request_url);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $return = curl_exec($ch);
    curl_close($ch);
    return $return;
}
$request_url = 'http://192.168.1.205/api.php?cname=David';
$response = apicall($request_url);

结果
codeS接听服务器(服务器2):结果


Codes for Answering Server (Server 2) are:

echo "Hello ".$_GET['cname'];

卷曲上都启用的Apache。所以为什么?我需要做什么?

cURL is enabled on both Apache. So why? What do i need to do?

推荐答案

这是无关的卷曲,这是你的Apache配置这就是问题所在。

This is nothing to do with cURL, it is your Apache configuration that is the problem.

Apache正在以这样的方式配置在资源 api.php 不可在其上你的脚本运行的机器。

Apache is configured in such a way the the resource at api.php is not available to the machine on which your script is running.

在你的Apache配置,在根目录下,你需要检查这些指令:

In you Apache configuration, for the root directory, you need to inspect these directives:

# Yours will not look like this
# The key point is look at the 'Order' and 'Allow'/'Deny' directives for the root directory
Order allow,deny
Allow from all

看一看并立即下面的章节吧。

另外,你可能有一些code某处 api.php ,看起来是这样的:

Alternatively, you may have some code somewhere in api.php that looks something like this:

header('HTTP/1.1 403 Forbidden');
exit("Access forbidden!\nYou don't have permission to access the requested object. It is either read-protected or not readable by the server.\nIf you think this is a server error, please contact the webmaster.\nError 403");

...但是,根据你说的是在code,我觉得这是对Apache的配置。

...however, based on what you say is in your code, I think this is about the Apache configuration.

这篇关于卷曲在Apache显示.."禁止访问!错误403"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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