2013-10-10 4 views
1

저는 Apache를 사용 중이며 index.html에서 jQuery를 사용하여 ajax 요청을 보냅니다. get_data.plcgi-bin에있는 파일입니다. 나는 403 Forbidden error을 얻었습니다. 누구든지 나를 도울 것이고 사전에 감사 할 것이다. 내가 콘솔에서 가지고 무엇Windows에서 Apache 403 오류 (금지됨)

$.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);  
}); 

:

{"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"} 

그것은 윈도우 7. 내가 관리자 계정을 사용하여 크롬으로 실행 해요입니다.

얼마 후 문제의 방법을 찾지 못했습니다. 전문가가 내 문제를 재현 할 수있는 세부 정보를 제공해야한다고 생각합니다. 에 라인 193 :

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

나는 2 개 라인 삭제 :

Order allow,deny 
Allow from all 

을 343 :

<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin"> 
     AllowOverride None 
     Options None 
     Order allow,deny 
     Allow from all 
</Directory> 
을 내 httpd.conf를 소개 , 나는 원래 하나를 기반으로 장소 변경

이 섹션을 다음으로 변경했습니다 :

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

.pl 파일을 cgi-bin 폴더에 htdocs 폴더의 index.html에 넣었습니다. Windows7, Win2k3 64 비트 및 WIn2k3 32 비트를 사용해 보았습니다. 모두 금지 된 오류가 있습니다. 나는 아파치의 기본 printenv.pl도 사용했다.

+1

'.htaccess'를 보여주세요. – haim770

+0

conf 폴더에서 검색했지만 .htaccess를 찾지 못했습니다. Apache2.2/manual 폴더 밑에 htaccess.html 만 있고, 내가 언급 한 설정 파일이라고 생각하지 않습니다. –

+0

다른 디렉토리 (예 :'/ image.jpg ')에 대한 다른 요청도 금지되어 있거나 단지'.pl' 파일입니까? – haim770

답변

1

난 당신이 CGI 물건을 실행할 수있는 권한을 누락하고 기본 설정 파일에이 같은 짧은 넣어 뭔가에서 Apache documentation

에서 활성화하는 방법에 대해 (https.conf)를 읽을 수 있다고 생각 :

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

앞으로 도움이되기를 바랍니다.

편집
스크립트에 액세스하는 데 사용 된 경로가 잘못되었습니다. 로그 파일은 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-bin 폴더에 있습니다. 변경 url: "get_data.pl" 호출에서 스크립트를 찾으려면 cgi-bin 문제를 해결했습니다.

+0

아니요, 해 보았습니다. AddHandler cgi-script .cgi .pl을 httpd.conf에 추가하면 경로는 Apache의 기본 cgi-bin입니다. 문제를 추적 할 수있는 방법은 없나요? –

+0

Importatnt 당신은'Options + ExecCGI'도 가지고 있지만 여러분이 가지고 있다고 가정합니다. 오류 로그 파일을 확인 하시겠습니까? 일반적으로'/ var/log/apache2' 아래에 있지만 구성에 따라 다를 수 있습니다. – Qben

+0

예, 로그 파일이 도움이됩니다. 나는 로그 파일이 "Options ExecCGI가이 디렉토리에서 떨어져있다 : C :/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/get_data.pl"을 체크했다. 사실, get_data.pl 파일은 htdocs 폴더에 있지만 cgi-bin 폴더에는 없습니다. 클라이언트 스크립트 "url :"get_data.pl ""을 호출하면 기본적으로 cgi-bin 폴더가 아닌 htdocs 폴더가 사용됩니다. 내가 그것에 어떻게 할당 될 수 있습니까? –