我的Apache错误消息提供以下内容(错误应该在最后一行):
[wsgi:error] [pid 17520] [client 192.168.0.117:56678] mod_wsgi (pid=17520): Exception occurred processing WSGI script '/var/www/vhosts/questionaireapp/quest/wsgi.py'., referer: http://questionaireapp:1337/
[wsgi:error][client 192.168.0.117:56678] Traceback (most recent call last):, referer: http://questionaireapp:1337/
[client 192.168.0.117:56678] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__, referer: http://questionaireapp:1337/
[wsgi:error][client 192.168.0.117:56678] response = self.get_response(request), referer: http://questionaireapp:1337/
[wsgi:error][client 192.168.0.117:56678] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 199, in get_response, referer: http://questionaireapp:1337/
[wsgi:error][client 192.168.0.117:56678] response = self.handle_uncaught_exception(request, resolver, sys.exc_info()), referer: http://questionaireapp:1337/
[wsgi:error][client 192.168.0.117:56678] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 239, in handle_uncaught_exception, referer: http://questionaireapp:1337/
[wsgi:error][client 192.168.0.117:56678] if resolver.urlconf_module is None:, referer: http://questionaireapp:1337/
[wsgi:error][client 192.168.0.117:56678] File "/usr/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 366, in urlconf_module, referer: http://questionaireapp:1337/
[wsgi:error][client 192.168.0.117:56678] self._urlconf_module = import_module(self.urlconf_name), referer: http://questionaireapp:1337/
[wsgi:error][client 192.168.0.117:56678] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module, referer: http://questionaireapp:1337/
[wsgi:error][client 192.168.0.117:56678] __import__(name), referer: http://questionaireapp:1337/
[wsgi:error][client 192.168.0.117:56678] ImportError: No module named quest.urls, referer: http://questionaireapp:1337/
我的wsgi.py文件是:
import os
import site
import sys
envpath= '/var/www/vhosts/questionaireapp/env/quest/bin/python2.7/site-packages'
pwd = os.path.dirname(os.path.abspath(__file__))
os.chdir(pwd)
sys.path= [pwd] + sys.path
site.addsitedir(envpath)
#sys.path.append(os.path.dirname(os.path.abspath(__file__)))
#os.environ.setdefault("DJANGO_SETTINGS_MODULE", "quest.settings")
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
application = WSGIHandler()
我的wsgi.py运行没有问题!
我的urls.py是:
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from quest import views
urlpatterns = patterns('',
url(r'^usercp/', include('usercp.urls')),
url(r'^questionaire/', include('exams.urls')),
url(r'^$', views.home, name="home"),
url(r'^admin/', include(admin.site.urls))
)
关于网址的我的settings.py是:
ROOT_URLCONF = 'quest.urls'
所有文件(wsgi设置和网址都在同一个文件夹中)
我的虚拟主机是:
WSGIPythonPath /var/www/vhosts/questionaireapp/quest
<VirtualHost *:1337>
WSGIDaemonProcess exams python-path=/var/www/vhosts/questionaireapp:/var/www/vhosts/questionaireapp/exams/lib/python2.7/site-packages
WSGIScriptAlias / /var/www/vhosts/questionaireapp/quest/wsgi.py
WSGIApplicationGroup %{GLOBAL}
ServerAdmin webmaster@localhost
ServerName questionaireapp
ServerAlias *.questionaireapp
DocumentRoot /var/www/vhosts/questionaireapp/
LogLevel info
Alias /static /var/www/vhosts/questionaireapp/static
<Directory /var/www/vhosts/questionaireapp>
AllowOverride None
Order allow,deny
allow from all
</Directory>