简体   繁体   English

Windows上的Apache 403错误(禁止)

[英]Apache 403 error (Forbidden) on windows

I'm using Apache and send an ajax request using jQuery from index.html . 我正在使用Apache,并使用jQuery从index.html发送ajax请求。 The get_data.pl is a file on cgi-bin . get_data.plcgi-bin上的文件。 I got 403 Forbidden error . 我收到403 Forbidden error Anyone would help me and thanks in advance. 任何人都会帮助我,在此先感谢。

$.ajax({
    async : true,
    type: "GET",
    url: "get_data.pl"      
}).done(function(msg){
    alert("Data Saved: " + msg);
}).fail(function(xmlHttpRequest,statusText,errorThrown) {   
    console.log(JSON.stringify(xmlHttpRequest));
    console.log(statusText);
    console.log(errorThrown);       
});

What I got from the console: 我从控制台得到的是:

{"readyState":4,"responseText":"<!DOCTYPE ...<title>403 Forbidden</title>...
<p>You don't have permission to access /get_data.pl\non this server.</p>\n</body>
</html>\n","status":403,"statusText":"Forbidden"} 

It's Windows 7. I'm running with Chrome using administrator account. 它是Windows7。我正在使用管理员帐户在Chrome上运行。

After some time, I didn't find ways for the issue yet. 一段时间后,我仍未找到解决该问题的方法。 I think I should provide more details for experts to reproduce my problem. 我想我应该为专家提供更多细节来重现我的问题。 About my httpd.conf, I changed places based on the original one: Line 193 in: 关于我的httpd.conf,我根据原始位置(第193行)更改了位置:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

I delete the 2 lines: 我删除了两行:

Order allow,deny
Allow from all

Line 343 : 343行:

<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin">
      AllowOverride None
      Options None
      Order allow,deny
      Allow from all
</Directory>

I changed this section to: 我将此部分更改为:

<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin">
AllowOverride None
    Options  +ExecCGI
    AddHandler cgi-script .cgi .pl
    Allow from all
</Directory>

I placed the .pl file in cgi-bin folder, the index.html in htdocs folder. 我将.pl文件放在cgi-bin文件夹中,将index.html放在htdocs文件夹中。 I tried Windows7, Win2k3 64bit and WIn2k3 32bit. 我尝试了Windows7,Win2k3 64位和WIn2k3 32位。 All have forbidden errors. 所有都有禁止的错误。 I used Apache's default printenv.pl also. 我也使用了Apache的默认printenv.pl。

I think you are missing permissions to run CGI stuff and you can read about how to enable it in the Apache documentation 我认为您缺少运行CGI内容的权限,可以在Apache文档中阅读有关如何启用它的信息。

In short put something like this in your main config file( https.conf ) : 简而言之,在您的主配置文件( https.conf )中https.conf

<Directory /path/to/cgi-bin/>
    Options +ExecCGI
    AddHandler cgi-script .pl
</Directory>

Hope it helps you forward. 希望它能帮助您前进。

EDIT 编辑
The problem was that the path used to access the script was incorrect. 问题是用于访问脚本的路径不正确。 Log file showed Options ExecCGI is off in this directory: C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/get_data.pl" while the get_data.pl file is not in htdocs , but in cgi-bin folder. Changing url: "get_data.pl" in the ajax call to locate the script in cgi-bin solved the problem. 日志文件显示Options ExecCGI is off in this directory: C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/get_data.pl"get_data.pl文件不在htdocs ,而在cgi-binajax调用中更改url: "get_data.pl"以在cgi-bin找到脚本解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM