【发布时间】:2015-03-18 04:22:27
【问题描述】:
所以在我的虚拟环境中,如果我激活它并输入python,2.7 版就会打开,应该是这样。
当 Django 出现错误时,它会显示 2.6 版本,这是系统默认值。这是我的 Apache 配置的样子:
<VirtualHost *:80>
ServerName www.mysite.com
ErrorLog /var/www/virtualenv-2.7/django-error-log
Alias /static/ /var/www/virtualenv-2.7/mysite/mainapp/static/
WSGIDaemonProcess mysite python-path=/var/www/virtualenv-2.7/mysite:/var/www/virtualenv-2.7/lib/python2.7/site-packages
WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/virtualenv-2.7/mysite/mysite/wsgi.py
<Directory /var/www/virtualenv-2.7>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
WSGISocketPrefix /var/run/wsgi
WSGIPythonPath /var/www/virtualenv-2.7/mysite:var/www/virutalenv-2.7/lib/python2.7/site-packages
我的 wsgi.py:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
当我service httpd restart 时,这是放在 apache 错误日志中的内容:
[Mon Jan 19 20:19:03 2015] [notice] caught SIGTERM, shutting down
[Mon Jan 19 20:19:04 2015] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Mon Jan 19 20:19:04 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Jan 19 20:19:04 2015] [notice] Digest: generating secret for digest authentication ...
[Mon Jan 19 20:19:04 2015] [notice] Digest: done
[Mon Jan 19 20:19:04 2015] [notice] Apache/2.2.15 (Unix) DAV/2 mod_wsgi/3.2 Python/2.6.6 configured -- resuming normal operations
知道为什么 Django 不使用虚拟环境中的 2.7 吗?
【问题讨论】:
-
可能是因为您的
mod_wsgi是针对系统 Python 编译的。检查 Apache 的错误日志以获取启动消息。 -
我从 apache error_log 添加了日志
标签: python django apache python-2.7 mod-wsgi