Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用mod_wsgi在apache2上为django提供服务时出错:没有名为settings的模块_Python_Django_Apache_Http_Mod Wsgi - Fatal编程技术网

Python 使用mod_wsgi在apache2上为django提供服务时出错:没有名为settings的模块

Python 使用mod_wsgi在apache2上为django提供服务时出错:没有名为settings的模块,python,django,apache,http,mod-wsgi,Python,Django,Apache,Http,Mod Wsgi,使用1个请求重新启动时的错误日志,出于某种原因,它似乎无法加载“中间件”?用于设置,以及一般的设置文件。这可能与权限有关,还是仅仅与我的配置有关 [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.1

使用1个请求重新启动时的错误日志,出于某种原因,它似乎无法加载“中间件”?用于设置,以及一般的设置文件。这可能与权限有关,还是仅仅与我的配置有关

[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
my 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> 
WSGIScriptAlias//srv/www/quickerhub.com/interest/django.wsgi
命令允许,拒绝
通融
我的网站已启用/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>
WSGIPythonPath/srv/www/quickerhub.com
ServerName quickerhub.com
ServerAlias testing.quickerhub.com
别名/static//srv/www/quickerhub.com/interest/static/
#别名/sitemap.xml/srv/www/quickerhub.com/interest/static/sitemap.xml
WSGIScriptAlias//srv/www/quickerhub.com/interest/django.wsgi
不允许超限
选项-索引
全盘否定
我的wsgi文件位于我站点的根路径中,因此我作弊:

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

您的
设置
位于
兴趣
下,但在
系统路径
中没有此路径。你知道吗?为什么不干脆
os.path.dirname(os.path.abspath(\uuu file\uuuu))
?这修复了我所有的错误,但我现在收到一个500错误,在allGood point Danil的apache日志中没有错误。我是在python新手时写的,它一直有效,所以我就离开了它。确保
导入sys,os,inspect
我打开了debug,收到了
sys.stdout访问权限受mod_wsgi
限制,然后关闭了wsgi限制,现在服务器没有响应。。
sys.path.append(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))