在apache,mod_wsgi,debian上部署django的奇怪错误

时间:2015-04-30 06:34:06

标签: python django apache mod-wsgi

在django 1.8上 在apache错误日志中得到

File "..../python2.7/site-packages/django/utils/lru_cache.py", line 28
fasttypes = {int, str, frozenset, type(None)},
SyntaxError: invalid syntax
谷歌搜索这似乎是一个错误,你运行django 1.7+并没有达到2.7的最低python要求。 然而

$ python --version
Python 2.7.3

这是apache虚拟主机配置的相关部分。

<VirtualHost <some_ip>:80>       
        WSGIDaemonProcess some_process python-path=/path/to/django-project/main-django-app:/path/to/virtual-env/site-packages/ threads=15 display-name=%{GROUP}
        WSGIProcessGroup some_group

        WSGIScriptAlias / /path/to/django-project/main-django-app/wsgi.py

        <Directory /path/to/django-project/main-django-app>
        <Files wsgi.py>
                Order deny,allow

                # Require all granted
                # for Apache < 2.4
                Allow from all
        </Files>
        </Directory>
</VirtualHost>

有没有人知道问题可能是什么?

1 个答案:

答案 0 :(得分:2)

您需要为您的python版本安装mod_wsgi。

如果您无法访问apache安装,可以使用pip直接在virtualenv中安装mod_wsgi。然后可以使用以下命令将其加载到您的服务器设置中:

全局设置:

LoadModule wsgi_module /path/to_your_env/path/to/mod_wsgi.so
WSGISocketPrefix run/wsgi
WSGIDaemonProcess 385969

虚拟主机:

WSGIScriptAlias / "/path/to/your/wsgi.py"
<Location />
    WSGIProcessGroup 385969 # this value must be identical to WSGIDaemonProcess
</Location>

最后,我是你的wsgi.py文件,你必须激活virtualenv。

相关问题