Mac에서 간단한 objective-CGI 프로그램을 실행하려고합니다. Apache2를 사용 중이며 OS X Mountain Lion을 실행 중입니다 (문제가있는 경우). 예를 들어 다음과 같은 코드를 가지고 : 나는 위의 코드를 컴파일, 그리고, CGI 디렉토리에 실행 파일을 복사 된 .cgi
확장명으로 이름을 변경하고, 권한을 실행했다Apache CGI로 실행 가능한 간단한 C 실행
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
// insert code here...
NSLog(@"Content-type: text/plain\r\n");
NSLog(@"From Cupertino, CA, we say, 'hello, World!'\r\n");
}
return 0;
}
.
나는 아파치에서 꽤 기본적인 설정을 사용했고, httpd.conf에서 지시어로 Option s ExecCGI
을 사용하고, AddHandler cgi-script .cgi
을 주석 처리하여 CGI 스크립트를 실행했다. 내가 파이썬 CGI 스크립트를 실행할 때 작동했지만 내 실행 파일 실행시 오류를 반환했습니다 :
90 [Sun Feb 09 20:01:33 2014] [error] [client ::1] 2014-02-09 20:01:33.247 testCGI.cgi[1498:707] Content-type: text/plain\r
2991 [Sun Feb 09 20:01:33 2014] [error] [client ::1] 2014-02-09 20:01:33.248 testCGI.cgi[1498:707] From Cupertino, CA, we say, 'hello, World!'\r
2992 [Sun Feb 09 20:01:33 2014] [error] [client ::1] Premature end of script headers: testCGI.cgi
어떤 아이디어가 왜 Premature end of script headers: testCGI.cgi
무엇입니까를?
미리 감사드립니다.
감사합니다. @Emmanuel. 아마 이것 (다른 것들 중에서)을 읽어야합니다 : https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/Reference/Reference.html – topmulch
@topmulch 환영하고, 네, 문서를 읽는 것은 일반적으로 좋은 생각입니다 :) – Emmanuel