2012-02-10 3 views
4

Lion (Mac OS X 10.7.3)을 실행중인 iMac에서 Python 2.7, Apache, mod_wsgi 및 web2py를 사용하여 웹 개발 환경을 설정하려고합니다. Exec 형식 오류 : Mac OS X Lion의 apache + mod_wsgi

나는 다운로드 mod_wsgi에 V 3.3 설치. (./configure 실행을, 만들기, sudo를 설치하게) 그것은는/usr/libexec 디렉토리/아파치를 설치

. 모든 분별 같습니다

07:49 PM ~ [541] otool -L /usr/libexec/apache2/mod_wsgi.so 
/usr/libexec/apache2/mod_wsgi.so: 
    /Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0) 
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0) 
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.19.0) 

07:55 PM ~ [542] file /usr/libexec/apache2/mod_wsgi.so 
/usr/libexec/apache2/mod_wsgi.so: Mach-O universal binary with 2 architectures 
/usr/libexec/apache2/mod_wsgi.so (for architecture x86_64): Mach-O 64-bit bundle x86_64 
/usr/libexec/apache2/mod_wsgi.so (for architecture i386): Mach-O bundle i386 

내가 모든을 LoadModule 지시어 후 /private/etc/apache2/httpd.conf 여러 설정 지시어를 추가했다.

LoadModule wsgi_module libexec/apache2/mod_wsgi.so 
WSGIScriptAlias//Library/WebServer/Documents 

아파치 데몬을 다시 시작했습니다.

[공지] Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 mod_wsgi/3.3 Python/2.7.2 구성 - 다시 시작 정상 작동

나는/라이브러리/웹 서버/문서 폴더에이 파일을 넣어

: 나는 내 브라우저에서 실행

def application(environ, start_response): 
    status = '200 OK' 
    output = 'Hello World!' 

    response_headers = [('Content-type', 'text/plain'), 
         ('Content-Length', str(len(output)))] 

    start_response(status, response_headers) 

    return [output] 

: http://192.168.1.2/test.py

내가 돌아왔다 "500 내부 서버 오류"응답

내 서버 로그는 말한다 :

[Thu Feb 09 20:12:10 2012] [error] [client 192.168.1.2] (8)Exec format error: exec of '/Library/WebServer/Documents/test.py' failed 
[Thu Feb 09 20:12:10 2012] [error] [client 192.168.1.2] Premature end of script headers: test.py 
[Thu Feb 09 20:12:10 2012] [error][client 192.168.1.2] mod_wsgi (pid=4251): Target WSGI script '/Library/WebServer/Documents/favicon.ico' does not contain WSGI application 'application'. 

많이 검색 한 후 나는 이유를 찾을 수가있다. 나는 심지어 문서 폴더에 favicon.ico를 붙였습니다. 이로 인해 기록이 남았습니다.

[Thu Feb 09 19:15:44 2012] [error] [client 192.168.1.2] (8)Exec format error: exec of '/Library/WebServer/Documents/test.py' failed 
[Thu Feb 09 19:15:44 2012] [error] [client 192.168.1.2] Premature end of script headers: test.py 
[Thu Feb 09 19:15:46 2012] [error] [client 192.168.1.2] mod_wsgi (pid=4135): Target WSGI script '/Library/WebServer/Documents/favicon.ico' does not contain WSGI application 'application'. 

아무 도움이됩니다.

+0

이 간부 형식의 오류가 도망 갔어요! 파이썬 소스 파일의 시작 부분에. "아직 끝나지 않은 스크립트 끝"오류 또는 "대상 WSGI 스크립트에 WSGI 응용 프로그램 '응용 프로그램이 없습니다."파일 사용 권한 (755) 및 인코딩 (UTF-8)을 확인했습니다. – david193

+0

왜 mod_python을 제목에 넣으시겠습니까? –

답변

1

WSGIScriptAlias를 DocumentRoot 디렉토리 자체와 디렉토리에 후행 슬래시없이 매핑 했으므로 WSGI 스크립트 파일과 같이 잘못된 방식으로 디렉토리를로드하려고 시도하는 중일 수 있습니다. 모든 mod_wsgi 설정을 포함하지 않았다면, 스크립트 파일의 조기 종료 메시지가 혼란 스럽습니다. 이 메시지는 표시되지 않은 mod_wsgi 데몬 모드를 사용하고 있거나 실제로 CGI 스크립트로 해석되고 있음을 나타냅니다. //192.168 :

<Directory /Library/WebServer/Documents> 
AddHandler wsgi-script .py 
Options +ExecCGI 
</Directory> 

이 'HTTP를 의미합니다 :

어쨌든, 당신이 아마 당신의 DocumentRoot에있는 파일을 평 드롭 할 경우 수행 할 할 것은 추가 한 후 WSGIScriptAlias을 제거하고 있습니다. 1.2/test.py '가 작동해야합니다. 그리고 그 디렉토리에 다른 정적 파일들을 여전히 드롭 할 수 있습니다.

당신이 개정 이동하십시오 : 나는 $ 넣을 때

http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide