【问题标题】:deploying a Django app on apache2 error在 apache2 错误上部署 Django 应用程序
【发布时间】:2014-05-12 14:33:55
【问题描述】:

我试图 deplpoy django 项目与 apache 和 mod_wsgi 一起工作,但得到这个错误:

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

【问题讨论】:

    标签: django deployment apache2


    【解决方案1】:

    您的 Apache HTTP 服务器是为 32 位还是 64 位处理器编译的?看起来 DLL 正在寻找 32 位版本的 Windows。

    【讨论】:

    • C:\Apache\bin&gt;httpd -v Server version: Apache/2.4.9 (Win64) Apache Lounge VC11 Server built: Mar 16 2014 12:42:59
    【解决方案2】:

    解决了

    所有 apache/wsgi_mod.so 和 python 需要是 64 位或 32 位 http://modwsgi.readthedocs.org/en/latest/installation-guides/installation-on-windows.html

    【讨论】:

      【解决方案3】:

      您可以尝试使用 32 位 Apache Http Server 吗? XAMPP 有一个可能更容易测试。

      【讨论】:

        猜你喜欢
        • 2017-02-01
        • 2018-03-30
        • 2016-04-15
        • 2016-03-30
        • 2018-04-21
        • 2021-12-07
        • 1970-01-01
        • 2015-11-21
        • 2020-08-02
        相关资源
        最近更新 更多