我試圖deplpoy Django項目與Apache和mod_wsgi的工作,但得到這個錯誤:部署上的Apache2錯誤Django應用程序
ImportError: DLL load failed: %1 n\x92est pas une application Win32 valide
這是我的wsgi.py文件
import os, sys
sys.path.append('C:/Users/abda/applica/projet/')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projet.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
這是在httpd.conf文件中的代碼
WSGIScriptAlias /t C:/Users/abda/applica/test.py
WSGIScriptAlias/C:/Users/abda/applica/projet/projet/wsgi.py
Alias /media/ C:/Users/abda/applica/projet/www/media/
Alias /static/ C:/Users/abda/applica/projet/www/static/
<Directory /abda/applica/projet/projet>
<Files wsgi.py>
Require all granted
</Files>
</Directory>`
此日誌錯誤返回
[Mon May 12 15:00:17.476950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] mod_wsgi (pid=13888): Target WSGI script 'C:/Users/abda/applica/projet/projet/wsgi.py' cannot be loaded as Python module.
[Mon May 12 15:00:17.476950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] mod_wsgi (pid=13888): Exception occurred processing WSGI script 'C:/Users/abda/applica/projet/projet/wsgi.py'.
[Mon May 12 15:00:17.476950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] Traceback (most recent call last):
[Mon May 12 15:00:17.476950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:/Users/abda/applica/projet/projet/wsgi.py", line 11, in <module>
[Mon May 12 15:00:17.477950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from django.core.wsgi import get_wsgi_application
[Mon May 12 15:00:17.477950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\lib\\site-packages\\django\\core\\wsgi.py", line 1, in <module>
[Mon May 12 15:00:17.477950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from django.core.handlers.wsgi import WSGIHandler
[Mon May 12 15:00:17.477950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 9, in <module>
[Mon May 12 15:00:17.478950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from django import http
[Mon May 12 15:00:17.478950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\lib\\site-packages\\django\\http\\__init__.py", line 1, in <module>
[Mon May 12 15:00:17.478950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from django.http.cookie import SimpleCookie, parse_cookie
[Mon May 12 15:00:17.478950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\lib\\site-packages\\django\\http\\cookie.py", line 3, in <module>
[Mon May 12 15:00:17.479950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from django.utils.encoding import force_str
[Mon May 12 15:00:17.479950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\lib\\site-packages\\django\\utils\\encoding.py", line 10, in <module>
[Mon May 12 15:00:17.480950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from urllib import quote
[Mon May 12 15:00:17.480950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\Lib\\urllib.py", line 26, in <module>
[Mon May 12 15:00:17.481950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] import socket
[Mon May 12 15:00:17.482950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\Lib\\socket.py", line 47, in <module>
[Mon May 12 15:00:17.482950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] import _socket
[Mon May 12 15:00:17.482950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] ImportError: DLL load failed: %1 n\x92est pas une application Win32 valide.
我用django1.5和apache2.4
'C:\ Apache \ bin> httpd -v服務器版本:Apache/2.4.9(Win64) Apache Lounge VC11服務器內置:2014年3月16日12:42:59' – Athari