2016-07-27 17 views
0

python3 manage.py runserverは正常に動作しますが、nginx/uwsgiで動作しますDjangoアプリケーションは動作しません。 Uwsgiログ:Djangoアプリはrunserverで動作しますが、uwsgiで失敗します

binary reloading uWSGI... 
chdir() to/
closing all non-uwsgi socket fds > 2 (max_fd = 1024)... 
found fd 3 mapped to socket 0 (/home/nginx/pythonworld.sock) 
running /usr/local/bin/uwsgi 
[uWSGI] getting INI configuration from /home/dmitriym/new_pythonworld/pythonworld_wsgi.ini 
*** Starting uWSGI 2.0.13.1 (64bit) on [Wed Jul 27 15:56:46 2016] *** 
compiled with version: 4.8.4 on 27 July 2016 18:42:57 
os: Linux-3.13.0-57-generiC#95-Ubuntu SMP Fri Jun 19 09:28:15 UTC 2015 
nodename: pythonworld.ru 
machine: x86_64 
clock source: unix 
pcre jit disabled 
detected number of CPU cores: 1 
current working directory:/
detected binary path: /usr/local/bin/uwsgi 
chdir() to /home/dmitriym/new_pythonworld/ 
your processes number limit is 7782 
your memory page size is 4096 bytes 
detected max file descriptor number: 1024 
lock engine: pthread robust mutexes 
thunder lock: disabled (you can enable it with --thunder-lock) 
uwsgi socket 0 inherited UNIX address /home/nginx/pythonworld.sock fd 3 
Python version: 3.4.3 (default, Oct 14 2015, 20:31:36) [GCC 4.8.4] 
*** Python threads support is disabled. You can enable it with --enable-threads *** 
Python main interpreter initialized at 0x14ac400 
your server socket listen backlog is limited to 100 connections 
your mercy for graceful operations on workers is 60 seconds 
mapped 145536 bytes (142 KB) for 1 cores 
*** Operational MODE: single process *** 
Traceback (most recent call last): 
    File "/usr/local/lib/python3.4/dist-packages/django/apps/config.py", line 107, in create 
    entry = module.default_app_config 
AttributeError: 'module' object has no attribute 'default_app_config' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "./new_pythonworld/wsgi.py", line 16, in <module> 
    application = get_wsgi_application() 
    File "/usr/local/lib/python3.4/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application 
    django.setup() 
    File "/usr/local/lib/python3.4/dist-packages/django/__init__.py", line 18, in setup 
    apps.populate(settings.INSTALLED_APPS) 
    File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 85, in populate 
    app_config = AppConfig.create(entry) 
    File "/usr/local/lib/python3.4/dist-packages/django/apps/config.py", line 110, in create 
    return cls(entry, module) 
    File "/usr/local/lib/python3.4/dist-packages/django/apps/config.py", line 40, in __init__ 
    self.path = self._path_from_module(app_module) 
    File "/usr/local/lib/python3.4/dist-packages/django/apps/config.py", line 73, in _path_from_module 
    "with a 'path' class attribute." % (module, paths)) 
django.core.exceptions.ImproperlyConfigured: The app module <module 'bookshop' (namespace)> has multiple filesystem locations (['./bookshop', '/home/dmitriym/new_pythonworld/bookshop']); you must configure this app with an AppConfig subclass with a 'path' class attribute. 
unable to load app 0 (mountpoint='') (callable not found or import error) 
*** no app loaded. going in full dynamic mode *** 
*** uWSGI is running in multiple interpreter mode *** 
gracefully (RE)spawned uWSGI master process (pid: 1329) 
spawned uWSGI worker 1 (pid: 1535, cores: 1) 

私は実際にアプリケーションディレクトリ内のinit の.pyファイルを持っています。 そしてapps.pyとのinitの.py

# apps.py 
from django.apps import AppConfig 

class MistypesConfig(AppConfig): 
    name = 'bookshop' 
    path = '/home/dmitriym/new_pythonworld/bookshop' 

    def ready(self): 
     pass 


# __init__.py 
default_app_config = 'bookshop.apps.MistypesConfig' 

を設定した後に、この問題はまだ表示されます。

プロジェクトのsettings.py

INSTALLED_APPS = (
    'mistypes', 
    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'vacancy', 
    'bookshop', 
) 

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware', 

    'django.middleware.gzip.GZipMiddleware', 

    'django.middleware.common.CommonMiddleware', 

    'django.middleware.csrf.CsrfViewMiddleware', 
    'django.contrib.auth.middleware.AuthenticationMiddleware', 
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 
    'django.contrib.messages.middleware.MessageMiddleware', 
    'django.middleware.security.SecurityMiddleware', 
) 

ROOT_URLCONF = 'new_pythonworld.urls' 
APPEND_SLASH = False 

TEMPLATES = [ 
    { 
     'BACKEND': 'django.template.backends.django.DjangoTemplates', 
     'DIRS': [os.path.join(BASE_DIR, 'templates')], 
     'APP_DIRS': True, 
     'OPTIONS': { 
      'context_processors': [ 
       #'django.template.context_processors.debug', 
       'django.contrib.auth.context_processors.auth', 
       'django.contrib.messages.context_processors.messages', 
      ], 
     }, 
    }, 
] 


WSGI_APPLICATION = 'new_pythonworld.wsgi.application' 


# Database 
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases 

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.sqlite3', 
     'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 
    } 
} 

pythonworld_wsgi.ini

[uwsgi] 
# Django-related settings 
# the base directory (full path) 
chdir   = /home/dmitriym/new_pythonworld 
# Djangos wsgi file 
module   = new_pythonworld.wsgi 
# process-related settings 
# master 
master   = true 
# maximum number of worker processes 
processes  = 1 
#enable-threads = true 
#threads   = 4 
# the socket (use the full path to be safe 
socket   = /home/nginx/pythonworld.sock 
# ... with appropriate permissions - may be needed 
chmod-socket = 664 
# clear environment on exit 
vacuum   = true 
# pid file 
pidfile   = /var/run/pythonworld.pid 
# logging 
logto   = /var/log/uwsgi/pythonworld.log 
#stats   = /tmp/statsock 
# uid and gid 
uid    = nginx 
gid    = www-data 

そしてnew_pythonworld/wsgi.py

""" 
WSGI config for new_pythonworld project. 

It exposes the WSGI callable as a module-level variable named ``application``. 

For more information on this file, see 
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ 
""" 

import os 

from django.core.wsgi import get_wsgi_application 

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "new_pythonworld.settings") 

application = get_wsgi_application() 
+0

'new_pythonworld.wsgi.application'とは何ですか? 'pythonworld_wsgi.ini'には何がありますか? – kichik

+0

new_pythonworld.wsgi.applicationとpythonworld_wsgi.iniが追加されました – DmitriyM

答えて

0

問題は、によって読み取られたソースコードを可能にするアクセス許可を変更することによって解決されましたuwsgiユーザー。

+0

これからやります:) –

+0

正しい答えを記入してください。 – Soviut

+0

2日後に回答を受け入れることができます:( – DmitriyM

関連する問題