我面临与 django wsgi 脚本相关的问题。我一直在为我的两个应用程序使用两个 virtualenv,并且我已经将这两个应用程序部署在具有不同端口的本地服务器上。第一个应用程序的 Apache 配置文件如下所示:
listen 8081
WSGIPythonPath /home/user/app1:/home/user/virtual-env1/lib/python2.7/site-packages
<VirtualHost mylocalip:8081>
ServerAdmin webmaster@localhost
ServerName www.app1.com
DocumentRoot /home/user/app1
<Directory /home/user/app1/static-root>
Options Indexes
Order Allow,Deny
Allow from all
IndexOptions FancyIndexing
</Directory>
<Directory /home/user/app1>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
WSGIScriptAlias / /home/user/app1/django.wsgi
WSGIPassAuthorization On
Alias "/static" /home/user/workspace/app1/static_root
</VirtualHost>
和第二个应用程序的 Apache 配置几乎相同,但我使用的是 virtual-env2 和不同的端口,而不是 virtual-env1。但是当我在服务器上运行我的第二个应用程序时,我得到了这个错误。
**AttributeError at /**
'Settings' object has no attribute 'DB_FILES'
Request Method: GET
Request URL: http://mylocalip:8091/
Django Version: 1.4.3
Exception Type: AttributeError
Exception Value: 'Settings' object has no attribute 'DB_FILES'
Exception Location: /home/user/virtual-env1/lib/python2.7/site-packages/django/utils/functional.py in inner, line 185
Python Executable: /usr/bin/python
Python Version: 2.7.2
Python Path:
['/home/user/virtual-env1/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
'/home/user/virtual-env1/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
'/home/user/app1',
'/home/user/virtual-env1/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/dist-packages/pip-1.1-py2.7.egg',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
'/home/user/app2',
'/home']
我的 django.wsgi 文件是这样的:
import os, sys
apache_configuration = os.path.dirname (__file__)
project = os.path.dirname (apache_configuration)
workspace = os.path.dirname (project)
sys.path.append ("/home/user/app2")
sys.path.append (workspace)
os.environ ['DJANGO_SETTINGS_MODULE'] = 'app2.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler ()
我不知道为什么我的服务器正在查看 virtual-env1 而不是 virtual-env2。请帮助我,因为我是 django 和 wsgi 的新手。