简体   繁体   English

使用mod_wsgi在apache2上投放django时出错:没有名为设置的模块

[英]error serving django on apache2 with mod_wsgi: No module named settings

The error log on restart with 1 request, for some reason it seems to be failing to load the "middleware"? 错误日志以1个请求重新启动,由于某种原因,它似乎无法加载“中间件”? for the settings, and the settings file in general. 设置和一般设置文件。 Could this have to do with permissions or just my configuration somehow? 这可能与权限有关,还是与我的配置有关?

[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

my file structure: 我的文件结构:

.
├── 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

my django.wsgi: EDITED 我的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()

my httpd.conf: 我的httpd.conf:

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

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

my sites-enabled/quickerhub.com: 我的sites-enabled / 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>
sys.path.append(rootpathofyoursite)

我的wsgi文件位于网站的根目录中,因此我作弊:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django + mod_wsgi + apache2:ImportError:未命名模块<project> - Django + mod_wsgi + apache2: ImportError: No module named <project> Ubuntu-Python-Apache2-Mod_WSGI-Django:没有名为/ TypeError / TemplateSyntaxError /&#39;str&#39;对象的模块不可调用 - Ubuntu - Python - Apache2 - Mod_WSGI - Django: No module named / TypeError / TemplateSyntaxError / 'str' object is not callable ImportError:没有名为appName.settings Django 1.8 + Apache + mod_wsgi的模块 - ImportError: No module named appName.settings django 1.8 + Apache + mod_wsgi Django/mod_wsgi/Apache - mod_wsgi 没有使用为它编译的 Python 版本 - “ModuleNotFoundError: No module named 'math'” - Django/mod_wsgi/Apache - mod_wsgi is not using the Python version it was compiled for - “ModuleNotFoundError: No module named 'math' ” Apache virtualenv和mod_wsgi:ImportError:没有名为&#39;django&#39;的模块 - Apache virtualenv and mod_wsgi : ImportError : No module named 'django' 找不到名为os的模块-Django,mod_wsgi,Apache 2.2 - No module named os found — Django, mod_wsgi, Apache 2.2 Django MOD_WSGI 设置? MOD_WSGI Apache2 403 您无权访问此资源 - Django MOD_WSGI Settings ? MOD_WSGI Apache2 403 You don't have permission to access this resource 500 内部服务器错误 mod_wsgi apache &quot;importerror: No Module named &#39;django&#39; - 500 internal server error mod_wsgi apache "importerror: No Module named 'django' 带有mod_wsgi的Apache上的Django:设置上的ImportError - Django on Apache with mod_wsgi: ImportError on settings django mod_wsgi 和 apache:找不到模块错误 - django mod_wsgi and apache: module not found error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM