2013-07-04 42 views
1

錯誤日誌重新啓動時出現1個請求,出於某種原因它似乎無法加載「中間件」?對於設置和一般的設置文件。這可能與權限或只是我的配置不知何故?在mod_wsgi上爲apache2服務django時出錯:沒有模塊命名設置

[Wed Jul 03 22:44:42 2013] [notice] Apache/2.2.14 (Ubuntu) mod_wsgi/2.8 Python/2.6.5 configured -- resuming normal operations 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] mod_wsgi (pid=6165): Exception occurred processing WSGI script '/srv/www/quickerhub.com/interest/django.wsgi'. 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] Traceback (most recent call last): 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] File "/usr/local/lib/python2.6/dist-packages/Django-1.5.1-py2.6.egg/django/core/handlers/wsgi.py", line 236, in __call__ 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252]  self.load_middleware() 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] File "/usr/local/lib/python2.6/dist-packages/Django-1.5.1-py2.6.egg/django/core/handlers/base.py", line 45, in load_middleware 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252]  for middleware_path in settings.MIDDLEWARE_CLASSES: 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] File "/usr/local/lib/python2.6/dist-packages/Django-1.5.1-py2.6.egg/django/conf/__init__.py", line 53, in __getattr__ 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252]  self._setup(name) 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] File "/usr/local/lib/python2.6/dist-packages/Django-1.5.1-py2.6.egg/django/conf/__init__.py", line 48, in _setup 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252]  self._wrapped = Settings(settings_module) 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] File "/usr/local/lib/python2.6/dist-packages/Django-1.5.1-py2.6.egg/django/conf/__init__.py", line 134, in __init__ 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252]  raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] mod_wsgi (pid=6166): Exception occurred processing WSGI script '/srv/www/quickerhub.com/interest/django.wsgi'. 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] Traceback (most recent call last): 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] File "/usr/local/lib/python2.6/dist-packages/Django-1.5.1-py2.6.egg/django/core/handlers/wsgi.py", line 236, in __call__ 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252]  self.load_middleware() 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] File "/usr/local/lib/python2.6/dist-packages/Django-1.5.1-py2.6.egg/django/core/handlers/base.py", line 45, in load_middleware 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252]  for middleware_path in settings.MIDDLEWARE_CLASSES: 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] File "/usr/local/lib/python2.6/dist-packages/Django-1.5.1-py2.6.egg/django/conf/__init__.py", line 53, in __getattr__ 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252]  self._setup(name) 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] File "/usr/local/lib/python2.6/dist-packages/Django-1.5.1-py2.6.egg/django/conf/__init__.py", line 48, in _setup 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252]  self._wrapped = Settings(settings_module) 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] File "/usr/local/lib/python2.6/dist-packages/Django-1.5.1-py2.6.egg/django/conf/__init__.py", line 134, in __init__ 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252]  raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) 
[Wed Jul 03 22:44:45 2013] [error] [client 74.192.126.252] ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings 

我的文件結構:

. 
├── logfile 
└── srv 
    ├── logfile 
    └── www 
     └── quickerhub.com 
      ├── admin 
      │ ├── css 
      │ │ ├── base.css 
      │ │ ├── changelists.css 
      │ │ ├── dashboard.css 
      │ │ ├── forms.css 
      │ │ ├── ie.css 
      │ │ ├── login.css 
      │ │ ├── rtl.css 
      │ │ └── widgets.css 
      │ ├── img 
      │ │ ├── changelist-bg.gif 
      │ │ ├── changelist-bg_rtl.gif 
      │ │ ├── chooser-bg.gif 
      │ │ ├── chooser_stacked-bg.gif 
      │ │ ├── default-bg.gif 
      │ │ ├── default-bg-reverse.gif 
      │ │ ├── deleted-overlay.gif 
      │ │ ├── gis 
      │ │ │ ├── move_vertex_off.png 
      │ │ │ └── move_vertex_on.png 
      │ │ ├── icon_addlink.gif 
      │ │ ├── icon_alert.gif 
      │ │ ├── icon_calendar.gif 
      │ │ ├── icon_changelink.gif 
      │ │ ├── icon_clock.gif 
      │ │ ├── icon_deletelink.gif 
      │ │ ├── icon_error.gif 
      │ │ ├── icon-no.gif 
      │ │ ├── icon_searchbox.png 
      │ │ ├── icon_success.gif 
      │ │ ├── icon-unknown.gif 
      │ │ ├── icon-yes.gif 
      │ │ ├── inline-delete-8bit.png 
      │ │ ├── inline-delete.png 
      │ │ ├── inline-restore-8bit.png 
      │ │ ├── inline-restore.png 
      │ │ ├── inline-splitter-bg.gif 
      │ │ ├── nav-bg.gif 
      │ │ ├── nav-bg-grabber.gif 
      │ │ ├── nav-bg-reverse.gif 
      │ │ ├── nav-bg-selected.gif 
      │ │ ├── selector-icons.gif 
      │ │ ├── selector-search.gif 
      │ │ ├── sorting-icons.gif 
      │ │ ├── tool-left.gif 
      │ │ ├── tool-left_over.gif 
      │ │ ├── tool-right.gif 
      │ │ ├── tool-right_over.gif 
      │ │ ├── tooltag-add.gif 
      │ │ ├── tooltag-add_over.gif 
      │ │ ├── tooltag-arrowright.gif 
      │ │ └── tooltag-arrowright_over.gif 
      │ └── js 
      │  ├── actions.js 
      │  ├── actions.min.js 
      │  ├── admin 
      │  │ ├── DateTimeShortcuts.js 
      │  │ ├── ordering.js 
      │  │ └── RelatedObjectLookups.js 
      │  ├── calendar.js 
      │  ├── collapse.js 
      │  ├── collapse.min.js 
      │  ├── core.js 
      │  ├── getElementsBySelector.js 
      │  ├── inlines.js 
      │  ├── inlines.min.js 
      │  ├── jquery.init.js 
      │  ├── jquery.js 
      │  ├── jquery.min.js 
      │  ├── LICENSE-JQUERY.txt 
      │  ├── prepopulate.js 
      │  ├── prepopulate.min.js 
      │  ├── SelectBox.js 
      │  ├── SelectFilter2.js 
      │  ├── timeparse.js 
      │  └── urlify.js 
      ├── interest 
      │ ├── django.wsgi 
      │ ├── __init__.py 
      │ ├── __init__.pyc 
      │ ├── settings.py 
      │ ├── settings.pyc 
      │ ├── urls.py 
      │ └── wsgi.py 
      ├── js 
      │ └── jquery-1.10.1.min.js 
      ├── logfile 
      ├── manage.py 
      ├── README 
      ├── reoccurring 
      │ ├── admin.py 
      │ ├── forms.py 
      │ ├── __init__.py 
      │ ├── __init__.pyc 
      │ ├── models.py 
      │ ├── models.pyc 
      │ ├── usagelib.py 
      │ └── views.py 
      ├── schedule 
      │ ├── admin.py 
      │ ├── __init__.py 
      │ ├── __init__.pyc 
      │ ├── models.py 
      │ ├── models.pyc 
      │ ├── tests.py 
      │ ├── usagelib.py 
      │ └── views.py 
      ├── src 
      │ ├── facebooksdk 
      │ │ ├── examples 
      │ │ │ ├── appengine 
      │ │ │ │ ├── app.yaml 
      │ │ │ │ ├── example.html 
      │ │ │ │ └── example.py 
      │ │ │ ├── newsfeed 
      │ │ │ │ ├── app.yaml 
      │ │ │ │ ├── facebookclient.py 
      │ │ │ │ ├── static 
      │ │ │ │ │ ├── base.css 
      │ │ │ │ │ ├── favicon.ico 
      │ │ │ │ │ └── robots.txt 
      │ │ │ │ └── templates 
      │ │ │ │  ├── base.html 
      │ │ │ │  ├── home.html 
      │ │ │ │  └── index.html 
      │ │ │ ├── oauth 
      │ │ │ │ ├── app.yaml 
      │ │ │ │ ├── facebookoauth.py 
      │ │ │ │ └── oauth.html 
      │ │ │ └── tornado 
      │ │ │  ├── example.html 
      │ │ │  ├── example.py 
      │ │ │  └── schema.sql 
      │ │ ├── facebook.py 
      │ │ ├── facebook_sdk.egg-info 
      │ │ │ ├── dependency_links.txt 
      │ │ │ ├── PKG-INFO 
      │ │ │ ├── SOURCES.txt 
      │ │ │ └── top_level.txt 
      │ │ ├── MANIFEST.in 
      │ │ ├── README.rst 
      │ │ └── setup.py 
      │ └── pip-delete-this-directory.txt 
      ├── static 
      │ └── js 
      │  └── jquery-1.10.1.min.js 
      ├── templates 
      │ ├── 404.html 
      │ ├── 500.html 
      │ ├── Base.html 
      │ ├── Home.html 
      │ ├── Reoccurring.html 
      │ └── Usersettings.html 
      └── usersetting 
       ├── admin.py 
       ├── __init__.py 
       ├── __init__.pyc 
       ├── models.py 
       ├── models.pyc 
       └── views.py 

我django.wsgi:已修改

import os 
import sys 

sys.path.append('/srv/www/quickerhub.com/') 

os.environ['DJANGO_SETTINGS_MODULE'] = 'interest.settings' 

import django.core.handlers.wsgi 
application = django.core.handlers.wsgi.WSGIHandler() 

我的httpd.conf:

WSGIScriptAlias//srv/www/quickerhub.com/interest/django.wsgi 

<Directory /srv/www/quickerhub.com> 
Order allow,deny 
Allow from all 
</Directory> 

我啓用的站點 -/quickerhub。 com:

WSGIPythonPath /srv/www/quickerhub.com 
<VirtualHost *:80> 
    ServerName quickerhub.com 
    ServerAlias testing.quickerhub.com 

    Alias /static/ /srv/www/quickerhub.com/interest/static/ 
    # Alias /sitemap.xml /srv/www/quickerhub.com/interest/static/sitemap.xml 
    WSGIScriptAlias//srv/www/quickerhub.com/interest/django.wsgi 

    <Directory /> 
     AllowOverride None 
     Options -Indexes 
    </Directory> 

    <Directory /srv/www/quickerhub.com/.git/> 
     Deny From All 
    </Directory> 

</VirtualHost> 
+0

你'settings'是在'interest'但你沒有在這個路徑中的' sys.path'。你做? – akonsu

回答

0
sys.path.append(rootpathofyoursite) 

我WSGI文件在我的網站的根路徑,所以我騙:

sys.path.append(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))) 
+0

爲什麼不只是'os.path.dirname(os.path.abspath(__ file __))'? –

+0

這固定了我所有的錯誤,但我現在收到了500錯誤,在apache日誌中沒有錯誤 – ljrh

+0

好點Daniil。當我更新python時,我寫了它,它一直工作,所以我剛剛離開它。 –

相關問題