如何在Apache + mod_wsgi

时间:2015-10-17 00:08:35

标签: python django apache mod-wsgi anaconda

我有一个使用numpy和其他库的django项目。我使用Anaconda(2.7 32位)作为Python解释器。我想使用Apache + mod_wsgi部署Django项目。

首先,我安装Apache24(VC9,32bit)+ Mod_wsgi。以下是我对httpd和wsgi文件的设置

在C:\ Apache24 \ conf \ httpd.conf中,我添加/修改以下内容

    Listen 8980
    LoadModule wsgi_module modules/mod_wsgi.so

    WSGIPythonHome "C:/Anaconda"

    WSGIPythonPath "C:/Apache24/htdocs/a;C:/Anaconda/libs;C:/Anaconda/Lib/site-packages"


    <VirtualHost *:8980> 
        ServerName 127.0.0.1

        WSGIScriptAlias / C:/Apache24/htdocs/a/project/wsgi.py
        <Directory C:/Apache24/htdocs/a/project>
        <Files wsgi.py>
            Require all granted
        </Files>
        </Directory>


        Alias /static "C:/Apache24/htdocs/a/static/static_root/"

        <Directory C:/Apache24/htdocs/a/static/static_root>
        Require all granted
        </Directory>

    </VirtualHost>
在Django项目的wsgi.py中

import sys
sys.path.append('C:/Apache24/htdocs/a') 
sys.path.append('C:/Apache24/htdocs/a/project') 

import site
site.addsitedir('C:\\Anaconda\\Lib\\site-packages')


import os

from django.core.wsgi import get_wsgi_application

# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "philips_crossover.settings")
os.environ["DJANGO_SETTINGS_MODULE"]= "project.settings"

application = get_wsgi_application()

我的探索是当我访问127.0.0.1:8980时,我收到错误。

在C:\ Apache24 \ logs \ errors.log

Traceback (most recent call last):
  File "C:/Apache24/htdocs/a/project/wsgi.py", line 20, in <module>
    from django.core.wsgi import get_wsgi_application
  File "C:\\Anaconda\\lib\\site-packages\\django\\core\\wsgi.py", line 2, in <module>
    from django.core.handlers.wsgi import WSGIHandler
  File "C:\\Anaconda\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 11, in <module>
    from django import http
  File "C:\\Anaconda\\lib\\site-packages\\django\\http\\__init__.py", line 1, in <module>
    from django.http.cookie import SimpleCookie, parse_cookie
  File "C:\\Anaconda\\lib\\site-packages\\django\\http\\cookie.py", line 6, in <module>
    from django.utils.encoding import force_str
  File "C:\\Anaconda\\lib\\site-packages\\django\\utils\\encoding.py", line 11, in <module>
    from django.utils.six.moves.urllib.parse import quote, unquote
  File "C:\\Anaconda\\lib\\site-packages\\django\\utils\\six.py", line 90, in __get__
    result = self._resolve()
  File "C:\\Anaconda\\lib\\site-packages\\django\\utils\\six.py", line 158, in _resolve
    module = _import_module(self.mod)
  File "C:\\Anaconda\\lib\\site-packages\\django\\utils\\six.py", line 80, in _import_module
    __import__(name)
  File "C:\\Anaconda\\lib\\urllib.py", line 26, in <module>
    import socket
  File "C:\\Anaconda\\lib\\socket.py", line 47, in <module>
    import _socket
ImportError: DLL load failed: The specified procedure could not be found.

0 个答案:

没有答案