Lionを実行しているiMac(Mac OS X 10.7.3)でPython 2.7、Apache、mod_wsgi、およびweb2pyを使用してWeb開発環境を設定しようとしています。実行形式エラー:Mac OS X Lionのapache + mod_wsgi
私はmod_wsgiをvをダウンロードしてインストール3.3(./configureを、作る; sudoはmake installを)。
をそれが、/ usr/libexecに/ apache2の中にインストールされています。すべては賢明になります
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デーモンを再起動しました。
[2011年2月9日19時19分15秒] [注意] Apache/2.2.21(Unix)mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 mod_wsgi/3.3 Python/2.7.2は、設定 - 私は/ライブラリ/ WebServer/Documentsフォルダにこのファイルを入れて通常の操作に
を再開:私は戻ったhttp://192.168.1.2/test.py
:私は私のブラウザからそれを実行
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]
"500 Internal Server error"という応答が返されました。
私のサーバーログは言う:
[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'.
助けていただければ幸いです。
私は$を入れたときに、EXECフォーマットエラーが去っていきました! pythonをソースファイルの先頭に追加します。私はまだ "スクリプトの早すぎる"エラー、または "対象WSGIスクリプトにはWSGIアプリケーション 'アプリケーションが含まれていません。"ファイルパーミッション(755)とエンコーディング(UTF-8)を確認しました – david193
なぜmod_pythonをタイトルに入れますか? –